From 5f1e95ff67573bd3b9855eee4179034067b69e21 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Tue, 2 Jun 2009 21:13:03 +0000 Subject: [PATCH 001/352] bugfix for Lib/perl5/reference.i (test-suite enhancements coming soon). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11244 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/perl5/reference.i | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index b7fde04cc..7cf00afaa 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-06-02: talby + [Perl] Resolved reference.i overload support problem + identfied by John Potowsky. + 2009-05-26: wsfulton [C#] Improved std::map wrappers based on patch from Yuval Baror. The C# proxy now implements System.Collections.Generic.IDictionary<>. diff --git a/Lib/perl5/reference.i b/Lib/perl5/reference.i index d3d745cfc..e03d0c303 100644 --- a/Lib/perl5/reference.i +++ b/Lib/perl5/reference.i @@ -202,6 +202,31 @@ as follows : $1 = &dvalue; } +%typemap(typecheck) int *REFERENCE, int &REFERENCE, + short *REFERENCE, short &REFERENCE, + long *REFERENCE, long &REFERENCE, + signed char *REFERENCE, unsigned char &REFERENCE, + bool *REFERENCE, bool &REFERENCE +{ + $1 = SvROK($input) && SvIOK(SvRV($input)); +} +%typemap(typecheck) double *REFERENCE, double &REFERENCE, + float *REFERENCE, float &REFERENCE +{ + $1 = SvROK($input); + if($1) { + SV *tmpsv = SvRV($input); + $1 = SvNOK(tmpsv) || SvIOK(tmpsv); + } +} +%typemap(typecheck) unsigned int *REFERENCE, unsigned int &REFERENCE, + unsigned short *REFERENCE, unsigned short &REFERENCE, + unsigned long *REFERENCE, unsigned long &REFERENCE, + unsigned char *REFERENCE, unsigned char &REFERENCE +{ + $1 = SvROK($input) && SvUOK(SvRV($input)); +} + %typemap(argout) double *REFERENCE, double &REFERENCE, float *REFERENCE, float &REFERENCE { From 54b87bdd7d021418a3ca4cae2a3f04df69c1ea4a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Jun 2009 17:19:29 +0000 Subject: [PATCH 002/352] remove extra lookup of directorout typemap git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11246 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/ocaml.cxx | 5 ----- Source/Modules/octave.cxx | 5 ----- Source/Modules/python.cxx | 5 ----- Source/Modules/ruby.cxx | 5 ----- 4 files changed, 20 deletions(-) diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index b925328a3..8a797759c 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1627,11 +1627,6 @@ public: Setattr(n, "type", return_type); tm = Swig_typemap_lookup("directorout", n, "c_result", w); Setattr(n, "type", type); - if (tm == 0) { - String *name = NewString("c_result"); - tm = Swig_typemap_search("directorout", return_type, name, NULL); - Delete(name); - } if (tm != 0) { Replaceall(tm, "$input", "swig_result"); /* TODO check this */ diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 39b61e93b..55ffe8cbb 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -1305,11 +1305,6 @@ public: Setattr(n, "type", return_type); tm = Swig_typemap_lookup("directorout", n, "result", w); Setattr(n, "type", type); - if (tm == 0) { - String *name = NewString("result"); - tm = Swig_typemap_search("directorout", return_type, name, NULL); - Delete(name); - } if (tm != 0) { char temp[24]; sprintf(temp, "out(%d)", idx); diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index bd22e79a6..73f280e6b 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -3949,11 +3949,6 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { Setattr(n, "type", return_type); tm = Swig_typemap_lookup("directorout", n, "result", w); Setattr(n, "type", type); - if (tm == 0) { - String *name = NewString("result"); - tm = Swig_typemap_search("directorout", return_type, name, NULL); - Delete(name); - } if (tm != 0) { if (outputs > 1) { Printf(w->code, "output = PyTuple_GetItem(result, %d);\n", idx++); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 1c13747e5..8d5ab4fae 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -3245,11 +3245,6 @@ public: Setattr(n, "type", return_type); tm = Swig_typemap_lookup("directorout", n, "result", w); Setattr(n, "type", type); - if (tm == 0) { - String *name = NewString("result"); - tm = Swig_typemap_search("directorout", return_type, name, NULL); - Delete(name); - } if (tm != 0) { if (outputs > 1 && !asvoid ) { Printf(w->code, "output = rb_ary_entry(result, %d);\n", idx++); From 1dc517575390fbcdb3c411753900c8ae7904f326 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Fri, 5 Jun 2009 18:47:30 +0000 Subject: [PATCH 003/352] reference.i improvements, testcase coverage. language specific interface support for test-suite. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11247 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 +- Examples/test-suite/perl5/Makefile.in | 1 + Examples/test-suite/perl5/byreference.i | 52 +++++++++++++++++++ .../test-suite/perl5/byreference_runme.pl | 36 +++++++++++++ Lib/perl5/reference.i | 10 ++-- 5 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/perl5/byreference.i create mode 100644 Examples/test-suite/perl5/byreference_runme.pl diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 5c6a332a4..753c5fbdf 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -64,7 +64,7 @@ INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) LIBS = -L. LIBPREFIX = lib ACTION = check -INTERFACEDIR = ../ +INTERFACEDIR = $(if $(wildcard $*.i), ./, ../) # # Please keep test cases in alphabetical order. diff --git a/Examples/test-suite/perl5/Makefile.in b/Examples/test-suite/perl5/Makefile.in index 3fee35bcb..518d341b2 100644 --- a/Examples/test-suite/perl5/Makefile.in +++ b/Examples/test-suite/perl5/Makefile.in @@ -15,6 +15,7 @@ CPP_TEST_CASES += \ li_cdata \ li_cstring \ li_cdata_carrays \ + byreference \ C_TEST_CASES += \ li_cdata \ diff --git a/Examples/test-suite/perl5/byreference.i b/Examples/test-suite/perl5/byreference.i new file mode 100644 index 000000000..43215f1cc --- /dev/null +++ b/Examples/test-suite/perl5/byreference.i @@ -0,0 +1,52 @@ +%module byreference + +%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 = FrVal + t; } + void RFloat(float &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PInt(int *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RInt(int &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PShort(short *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RShort(short &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PLong(long *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RLong(long &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PUInt(unsigned int *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RUInt(unsigned int &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PUShort(unsigned short *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RUShort(unsigned short &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PULong(unsigned long *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RULong(unsigned long &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PUChar(unsigned char *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RUChar(unsigned char &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PChar(signed char *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RChar(signed char &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PBool(bool *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RBool(bool &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } +%} diff --git a/Examples/test-suite/perl5/byreference_runme.pl b/Examples/test-suite/perl5/byreference_runme.pl new file mode 100644 index 000000000..845d870cd --- /dev/null +++ b/Examples/test-suite/perl5/byreference_runme.pl @@ -0,0 +1,36 @@ +use strict; +use warnings; +use Test::More tests => 68; +BEGIN { use_ok('byreference') } +require_ok('byreference'); + +sub chk { my($type, $call, $v1, $v2) = @_; + $byreference::FrVal = $v1; + my $v = $v2; + eval { $call->(\$v) }; + is($@, '', "$type check"); + is($byreference::ToVal, $v2, "$type out"); + is($v, $v1, "$type in"); +} +chk("double*", \&byreference::PDouble, 12.2, 18.6); +chk("double&", \&byreference::RDouble, 32.5, 64.8); +chk("float*", \&byreference::PFloat, 64.5, 96.0); +chk("float&", \&byreference::RFloat, 98.5, 6.25); +chk("int*", \&byreference::PInt, 1887, 3356); +chk("int&", \&byreference::RInt, 2622, 9867); +chk("short*", \&byreference::PShort, 4752, 3254); +chk("short&", \&byreference::RShort, 1898, 5757); +chk("long*", \&byreference::PLong, 6687, 7132); +chk("long&", \&byreference::RLong, 8346, 4398); +chk("uint*", \&byreference::PUInt, 6853, 5529); +chk("uint&", \&byreference::RUInt, 5483, 7135); +chk("ushort*", \&byreference::PUShort, 9960, 9930); +chk("ushort&", \&byreference::RUShort, 1193, 4178); +chk("ulong*", \&byreference::PULong, 7960, 4788); +chk("ulong&", \&byreference::RULong, 8829, 1603); +chk("uchar*", \&byreference::PUChar, 110, 239); +chk("uchar&", \&byreference::RUChar, 15, 97); +chk("char*", \&byreference::PChar, -7, 118); +chk("char&", \&byreference::RChar, -3, -107); +chk("bool*", \&byreference::PBool, 0, 1); +chk("bool&", \&byreference::RBool, 1, 0); diff --git a/Lib/perl5/reference.i b/Lib/perl5/reference.i index e03d0c303..6f5eda518 100644 --- a/Lib/perl5/reference.i +++ b/Lib/perl5/reference.i @@ -205,7 +205,7 @@ as follows : %typemap(typecheck) int *REFERENCE, int &REFERENCE, short *REFERENCE, short &REFERENCE, long *REFERENCE, long &REFERENCE, - signed char *REFERENCE, unsigned char &REFERENCE, + signed char *REFERENCE, signed char &REFERENCE, bool *REFERENCE, bool &REFERENCE { $1 = SvROK($input) && SvIOK(SvRV($input)); @@ -224,7 +224,11 @@ as follows : unsigned long *REFERENCE, unsigned long &REFERENCE, unsigned char *REFERENCE, unsigned char &REFERENCE { - $1 = SvROK($input) && SvUOK(SvRV($input)); + $1 = SvROK($input); + if($1) { + SV *tmpsv = SvRV($input); + $1 = SvUOK(tmpsv) || SvIOK(tmpsv); + } } %typemap(argout) double *REFERENCE, double &REFERENCE, @@ -239,7 +243,7 @@ as follows : %typemap(argout) int *REFERENCE, int &REFERENCE, short *REFERENCE, short &REFERENCE, long *REFERENCE, long &REFERENCE, - signed char *REFERENCE, unsigned char &REFERENCE, + signed char *REFERENCE, signed char &REFERENCE, bool *REFERENCE, bool &REFERENCE { SV *tempsv; From 16ef97f362df4332f9626823e830e17a0722d124 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 15 Jun 2009 12:27:21 +0000 Subject: [PATCH 004/352] Remove non-standard targets makecpptests, makectests, maketests, runcpptests, runctests, runtests - the C ones at least don't work properly, and haven't for a long time. Remove explicit use of bash from missingcpptests and missingctests as it isn't required and bash may not be available. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11259 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/Makefile.in | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index b8aeaaa11..d48f37e8a 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -16,28 +16,12 @@ include $(srcdir)/../common.mk # Overridden variables here TARGETPREFIX =# Should be php_ for Windows, empty otherwise -makecpptests: - @bash -ec 'for test in $(CPP_TEST_CASES) ; do $(MAKE) clean && $(MAKE) $${test}.cpptest; done' - -maketests: makecpptests makectests - -makectests: - @bash -ec 'for test in $(C_TEST_CASES) ; do $($(MAKE)) clean && $(MAKE) $${test}.cpptest; done' - -runcpptests: - @bash -ec 'for test in $(CPP_TEST_CASES) ; do if [ -f $${test}_runme.php ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi ; done' - -runctests: - @bash -ec 'for test in $(C_TEST_CASES) ; do if [ -f $${test}_runme.php ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi; done' - -runtests: runcpptests runctests - # write out tests without a _runme.php missingcpptests: - @bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done' + for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done missingctests: - @bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done' + for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done missingtests: missingcpptests missingctests From 0a1c7c91b1ac41306e2054123be3f0aa58bfc651 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 16 Jun 2009 19:29:08 +0000 Subject: [PATCH 005/352] fix Java and C# enums when one of the enum items is ignored git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11279 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 ++ .../test-suite/csharp/enum_thorough_runme.cs | 39 +++++++++++++ .../csharp/enum_thorough_simple_runme.cs | 39 +++++++++++++ .../csharp/enum_thorough_typesafe_runme.cs | 39 +++++++++++++ Examples/test-suite/enum_thorough.i | 45 ++++++++++++++ Examples/test-suite/enum_thorough_typesafe.i | 2 + .../java/enum_thorough_proper_runme.java | 39 +++++++++++++ .../test-suite/java/enum_thorough_runme.java | 39 +++++++++++++ .../java/enum_thorough_simple_runme.java | 39 +++++++++++++ .../java/enum_thorough_typeunsafe_runme.java | 39 +++++++++++++ .../test-suite/perl5/enum_thorough_runme.pl | 47 +++++++++++++-- Source/Modules/csharp.cxx | 2 +- Source/Modules/java.cxx | 2 +- Source/Modules/typepass.cxx | 58 +++++++++++++++++-- 14 files changed, 422 insertions(+), 12 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 7cf00afaa..a3b0bcd27 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.40 (in progress) ============================ +2009-06-16: wsfulton + [Java,C#] Fix enum marshalling when %ignore is used on one of the enum items reported + by Lubomir Konstantinov. Incorrect enum values were being passed to the C++ layer or + compilation errors resulted. + 2009-06-02: talby [Perl] Resolved reference.i overload support problem identfied by John Potowsky. diff --git a/Examples/test-suite/csharp/enum_thorough_runme.cs b/Examples/test-suite/csharp/enum_thorough_runme.cs index 765347e4b..d68e2b5fa 100644 --- a/Examples/test-suite/csharp/enum_thorough_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_runme.cs @@ -358,6 +358,45 @@ public class runme { 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"); diff --git a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs index f8556ff37..4a2f240c1 100644 --- a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs @@ -358,6 +358,45 @@ public class runme { 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"); diff --git a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs index dc2a981de..638885c52 100644 --- a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs @@ -358,6 +358,45 @@ public class runme { 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"); diff --git a/Examples/test-suite/enum_thorough.i b/Examples/test-suite/enum_thorough.i index 31e3e2105..8de97decb 100644 --- a/Examples/test-suite/enum_thorough.i +++ b/Examples/test-suite/enum_thorough.i @@ -487,10 +487,55 @@ struct Instances { // 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; } +%} + +#warning TODO: remove SWIGPERL code - replace with portable symbols + #if defined(SWIGPERL) %inline %{ diff --git a/Examples/test-suite/enum_thorough_typesafe.i b/Examples/test-suite/enum_thorough_typesafe.i index 8bae5b07a..e205e8ad1 100644 --- a/Examples/test-suite/enum_thorough_typesafe.i +++ b/Examples/test-suite/enum_thorough_typesafe.i @@ -3,5 +3,7 @@ // 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/Examples/test-suite/java/enum_thorough_proper_runme.java b/Examples/test-suite/java/enum_thorough_proper_runme.java index 243d3bddd..39d50ea38 100644 --- a/Examples/test-suite/java/enum_thorough_proper_runme.java +++ b/Examples/test-suite/java/enum_thorough_proper_runme.java @@ -369,6 +369,45 @@ public class enum_thorough_proper_runme { 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"); diff --git a/Examples/test-suite/java/enum_thorough_runme.java b/Examples/test-suite/java/enum_thorough_runme.java index 1cd02d38d..ce90ccb22 100644 --- a/Examples/test-suite/java/enum_thorough_runme.java +++ b/Examples/test-suite/java/enum_thorough_runme.java @@ -369,6 +369,45 @@ public class enum_thorough_runme { 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"); diff --git a/Examples/test-suite/java/enum_thorough_simple_runme.java b/Examples/test-suite/java/enum_thorough_simple_runme.java index 9bd56273e..bc3e3123d 100644 --- a/Examples/test-suite/java/enum_thorough_simple_runme.java +++ b/Examples/test-suite/java/enum_thorough_simple_runme.java @@ -369,6 +369,45 @@ public class enum_thorough_simple_runme { 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"); diff --git a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java index 35d1a1937..27aba72d4 100644 --- a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java +++ b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java @@ -369,6 +369,45 @@ public class enum_thorough_typeunsafe_runme { 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"); diff --git a/Examples/test-suite/perl5/enum_thorough_runme.pl b/Examples/test-suite/perl5/enum_thorough_runme.pl index 80a2ccae9..8be59364f 100644 --- a/Examples/test-suite/perl5/enum_thorough_runme.pl +++ b/Examples/test-suite/perl5/enum_thorough_runme.pl @@ -1,7 +1,7 @@ # an adaptation of ../java/enum_thorough_runme.java use strict; use warnings; -use Test::More tests => 272; +use Test::More tests => 299; BEGIN { use_ok('enum_thorough') } require_ok('enum_thorough'); @@ -348,6 +348,45 @@ SKIP: { $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"); @@ -368,8 +407,8 @@ SKIP: { 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 failed"); + $enum_thorough::SpeedClass::slow, "speedTest Global 5"); is(enum_thorough::speedTest4($enum_thorough::SpeedClass::fast), - $enum_thorough::SpeedClass::fast, "speedTest Global 4 failed"); + $enum_thorough::SpeedClass::fast, "speedTest Global 4"); is(enum_thorough::speedTest5($enum_thorough::SpeedClass::fast), - $enum_thorough::SpeedClass::fast, "speedTest Global 5 failed"); + $enum_thorough::SpeedClass::fast, "speedTest Global 5"); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 05d5c72e1..ad6830ec6 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1227,7 +1227,7 @@ public: if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) { // Wrap (non-anonymous) C/C++ enum with a proper C# enum // Emit the enum item. - if (!Getattr(n, "_last")) // Only the first enum item has this attribute set + if (!GetFlag(n, "firstenumitem")) Printf(enum_code, ",\n"); Printf(enum_code, " %s", symname); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 72556a04b..50ef506ed 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1283,7 +1283,7 @@ public: if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) { // Wrap (non-anonymous) C/C++ enum with a proper Java enum // Emit the enum item. - if (!Getattr(n, "_last")) // Only the first enum item has this attribute set + if (!GetFlag(n, "firstenumitem")) Printf(enum_code, ",\n"); Printf(enum_code, " %s", symname); if (Getattr(n, "enumvalue")) { diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index d663aed6e..9b42bc1a3 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -730,6 +730,49 @@ class TypePass:private Dispatcher { } Setattr(n, "enumtype", enumtype); + // This block of code is for dealing with %ignore on an enum item where the target language + // attempts to use the C enum value in the target language itself and expects the previous enum value + // to be one more than the previous value... the previous enum item might not exist if it is ignored! + // - It sets the first non-ignored enum item with the "firstenumitem" attribute. + // - It adds an enumvalue attribute if the previous enum item is ignored + { + Node *c; + int count = 0; + String *previous = 0; + bool previous_ignored = false; + bool firstenumitem = false; + for (c = firstChild(n); c; c = nextSibling(c)) { + assert(strcmp(Char(nodeType(c)), "enumitem") == 0); + + bool reset; + String *enumvalue = Getattr(c, "enumvalue"); + if (GetFlag(c, "feature:ignore")) { + reset = enumvalue ? true : false; + previous_ignored = true; + } else { + if (!enumvalue && previous_ignored) { + if (previous) + Setattr(c, "enumvalue", NewStringf("(%s) + %d", previous, count+1)); + else + Setattr(c, "enumvalue", NewStringf("%d", count)); + SetFlag(c, "virtenumvalue"); // identify enumvalue as virtual, ie not from the parsed source + } + if (!firstenumitem) { + SetFlag(c, "firstenumitem"); + firstenumitem = true; + } + reset = true; + previous_ignored = false; + } + if (reset) { + previous = enumvalue ? enumvalue : Getattr(c, "name"); + count = 0; + } else { + count++; + } + } + } + emit_children(n); return SWIG_OK; } @@ -753,13 +796,16 @@ class TypePass:private Dispatcher { Setattr(n, "value", new_value); Delete(new_value); } - // Make up an enumvalue if one was not specified in the parsed code - if (Getattr(n, "_last") && !Getattr(n, "enumvalue")) { // Only the first enum item has _last set - Setattr(n, "enumvalueex", "0"); - } Node *next = nextSibling(n); - if (next && !Getattr(next, "enumvalue")) { - Setattr(next, "enumvalueex", NewStringf("%s + 1", Getattr(n, "sym:name"))); + + // Make up an enumvalue if one was not specified in the parsed code (not designed to be used on enum items and %ignore - enumvalue will be set instead) + if (!GetFlag(n, "feature:ignore")) { + if (Getattr(n, "_last") && !Getattr(n, "enumvalue")) { // Only the first enum item has _last set (Note: first non-ignored enum item has firstenumitem set) + Setattr(n, "enumvalueex", "0"); + } + if (next && !Getattr(next, "enumvalue")) { + Setattr(next, "enumvalueex", NewStringf("%s + 1", Getattr(n, "sym:name"))); + } } return SWIG_OK; From 222b9e4710891aac04073a43c08d839813805699 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 16 Jun 2009 20:26:28 +0000 Subject: [PATCH 006/352] remove perl specific modifications to the enum_thorough test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11280 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/csharp/enum_thorough_runme.cs | 2 +- .../csharp/enum_thorough_simple_runme.cs | 2 +- .../csharp/enum_thorough_typesafe_runme.cs | 2 +- Examples/test-suite/enum_thorough.i | 24 ------------------- .../java/enum_thorough_proper_runme.java | 2 +- .../test-suite/java/enum_thorough_runme.java | 2 +- .../java/enum_thorough_simple_runme.java | 2 +- .../java/enum_thorough_typeunsafe_runme.java | 2 +- .../test-suite/perl5/enum_thorough_runme.pl | 9 ++----- 9 files changed, 9 insertions(+), 38 deletions(-) diff --git a/Examples/test-suite/csharp/enum_thorough_runme.cs b/Examples/test-suite/csharp/enum_thorough_runme.cs index d68e2b5fa..144736f2b 100644 --- a/Examples/test-suite/csharp/enum_thorough_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_runme.cs @@ -402,7 +402,7 @@ public class runme { 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.last) != 3) throw new Exception("repeatTest 5 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/Examples/test-suite/csharp/enum_thorough_simple_runme.cs b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs index 4a2f240c1..d5bba1b7d 100644 --- a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs @@ -402,7 +402,7 @@ public class runme { 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.last) != 3) throw new Exception("repeatTest 5 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/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs index 638885c52..3606d1137 100644 --- a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs @@ -402,7 +402,7 @@ public class runme { 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.last).swigValue != 3) throw new Exception("repeatTest 5 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/Examples/test-suite/enum_thorough.i b/Examples/test-suite/enum_thorough.i index 8de97decb..974227a01 100644 --- a/Examples/test-suite/enum_thorough.i +++ b/Examples/test-suite/enum_thorough.i @@ -534,9 +534,6 @@ IgnoreTest::IgnoreD ignoreDTest(IgnoreTest::IgnoreD n) { return n; } IgnoreTest::IgnoreE ignoreETest(IgnoreTest::IgnoreE n) { return n; } %} -#warning TODO: remove SWIGPERL code - replace with portable symbols - -#if defined(SWIGPERL) %inline %{ namespace RepeatSpace { @@ -554,24 +551,3 @@ repeat repeatTest(repeat e) { return e; } %} -#else -%inline %{ - -namespace RepeatSpace { -typedef enum -{ - one = 1, - initial = one, - two, - three, - last = three, - end = last -} repeat; -repeat repeatTest(repeat e) { return e; } -} - -%} - - -#endif - diff --git a/Examples/test-suite/java/enum_thorough_proper_runme.java b/Examples/test-suite/java/enum_thorough_proper_runme.java index 39d50ea38..66968060d 100644 --- a/Examples/test-suite/java/enum_thorough_proper_runme.java +++ b/Examples/test-suite/java/enum_thorough_proper_runme.java @@ -413,7 +413,7 @@ public class enum_thorough_proper_runme { 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.last).swigValue() != 3) throw new RuntimeException("repeatTest 5 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/Examples/test-suite/java/enum_thorough_runme.java b/Examples/test-suite/java/enum_thorough_runme.java index ce90ccb22..79c902ccf 100644 --- a/Examples/test-suite/java/enum_thorough_runme.java +++ b/Examples/test-suite/java/enum_thorough_runme.java @@ -413,7 +413,7 @@ public class enum_thorough_runme { 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.last).swigValue() != 3) throw new RuntimeException("repeatTest 5 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/Examples/test-suite/java/enum_thorough_simple_runme.java b/Examples/test-suite/java/enum_thorough_simple_runme.java index bc3e3123d..e54acda70 100644 --- a/Examples/test-suite/java/enum_thorough_simple_runme.java +++ b/Examples/test-suite/java/enum_thorough_simple_runme.java @@ -413,7 +413,7 @@ public class enum_thorough_simple_runme { 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.last) != 3) throw new RuntimeException("repeatTest 5 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/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java index 27aba72d4..b00788911 100644 --- a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java +++ b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java @@ -413,7 +413,7 @@ public class enum_thorough_typeunsafe_runme { 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.last) != 3) throw new RuntimeException("repeatTest 5 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/Examples/test-suite/perl5/enum_thorough_runme.pl b/Examples/test-suite/perl5/enum_thorough_runme.pl index 8be59364f..66e719275 100644 --- a/Examples/test-suite/perl5/enum_thorough_runme.pl +++ b/Examples/test-suite/perl5/enum_thorough_runme.pl @@ -1,7 +1,7 @@ # an adaptation of ../java/enum_thorough_runme.java use strict; use warnings; -use Test::More tests => 299; +use Test::More tests => 298; BEGIN { use_ok('enum_thorough') } require_ok('enum_thorough'); @@ -392,12 +392,7 @@ SKIP: { 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"); -{ local $TODO = "overzealous keyword guarding"; - ok(defined($enum_thorough::last), "found enum value"); -SKIP: { - skip "enum value not in expected package", 1 unless defined $enum_thorough::last; - is(enum_thorough::repeatTest($enum_thorough::last), 3, "repeatTest 5"); -}} + is(enum_thorough::repeatTest($enum_thorough::llast), 3, "repeatTest 5"); is(enum_thorough::repeatTest($enum_thorough::end), 3, "repeatTest 6"); } From d833dc83f06ede4fcf4c2a57677783e1f0990ad6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 16 Jun 2009 20:39:53 +0000 Subject: [PATCH 007/352] fix error in bug reporter for enums and %ignore git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11281 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index a3b0bcd27..822d2feed 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,9 +2,8 @@ Version 1.3.40 (in progress) ============================ 2009-06-16: wsfulton - [Java,C#] Fix enum marshalling when %ignore is used on one of the enum items reported - by Lubomir Konstantinov. Incorrect enum values were being passed to the C++ layer or - compilation errors resulted. + [Java,C#] Fix enum marshalling when %ignore is used on one of the enum items. + Incorrect enum values were being passed to the C++ layer or compilation errors resulted. 2009-06-02: talby [Perl] Resolved reference.i overload support problem From c3dba3315b45d128d7d24ae69e96a14130cc3ee5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 17 Jun 2009 06:50:39 +0000 Subject: [PATCH 008/352] better clarification for %include and #include and %module git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11282 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 3 ++- Doc/Manual/Java.html | 6 ++++++ Doc/Manual/SWIG.html | 29 +++++++++++++++++++++-------- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 3e17ee7f1..f747fc213 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -99,6 +99,7 @@ namespace com.bloggs.widget { ... } +Note that by default, the generated C# classes have no namespace and the module name is unrelated to namespaces. The module name is just like in Java and is merely used to name some of the generated classes.
  • @@ -131,7 +132,7 @@ If it was used, it would generate an illegal runtime initialisation via a PInvok C# doesn't support the notion of throws clauses. Therefore there is no 'throws' typemap attribute support for adding exception classes to a throws clause. Likewise there is no need for an equivalent to %javaexception. -In fact, throwing C# exceptions works quite differently, see C# Exceptions> below. +In fact, throwing C# exceptions works quite differently, see C# Exceptions below.
  • diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index a19cc5e84..2cde5ddab 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -253,6 +253,12 @@ To change this, you can use the -o option. It is also possible to change the output directory that the Java files are generated into using -outdir.

    +

    +The module name, specified with %module, determines the name of various generated classes as discussed later. +Note that the module name does not define a Java package and by default, the generated Java classes do not have a Java package. +The -package option described below can specify a Java package name to use. +

    +

    The following sections have further practical examples and details on how you might go about compiling and using the generated files. diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index d52f0441c..3cbd3cf21 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -177,8 +177,10 @@ int bar(int x); The name of the module is supplied using the special %module directive (or the -module command line option). This directive must appear at the beginning of the file and is used to name -the resulting extension module (in addition, this name often defines -a namespace in the target language). If the module name is supplied on the +the resulting target language extension module. Exactly what this results +in depends on the target language, eg the module name can define +a target language namespace or merely be a useful name for naming files or helper classes. +If the module name is supplied on the command line, it overrides the name specified with the %module directive.

    @@ -2361,7 +2363,7 @@ You can make a Vector look a lot like a class by writing a SWIG interfa #include "vector.h" %} -%include vector.h // Just grab original C header file +%include "vector.h" // Just grab original C header file %extend Vector { // Attach these functions to struct Vector Vector(double x, double y, double z) { Vector *v; @@ -2883,10 +2885,16 @@ interface to your program. SWIG's %include directive to process an entire C source/header file. -
  • Make sure everything in the interface file uses ANSI C/C++syntax. +
  • Make sure everything in the interface file uses ANSI C/C++ syntax.
  • Make sure all necessary `typedef' declarations and -type-information is available in the interface file. +type-information is available in the interface file. +In particular, ensure that the type information is specified in the correct order as required by a C compiler. +In particular, define a type before it is used! A C compiler will tell you +if the full type information is not available when it is needed, whereas +SWIG will usually not warn or error out as it is designed to work without +full type information. However, if type information is not specified +correctly, the wrappers can be sub-optimal.
  • If your program has a main() function, you may need to rename it (read on). @@ -2945,16 +2953,21 @@ extern void dump(FILE *f);

    Of course, in this case, our header file is pretty simple so we could -have made an interface file like this as well:

    +use a simpler approach and use an interface file like this:

     /* File : interface.i */
     %module mymodule
    -%include header.h
    +%{
    +#include "header.h"
    +%}
    +%include "header.h"
     

    -Naturally, your mileage may vary.

    +The main advantage of this approach is minimal maintenance of an interface file for when the header file changes in the future. +In more complex projects, an interface file containing numerous %include and #include statements like this is one of the most common approaches to interface file design due to lower maintenance overhead. +

    5.7.3 Why use separate interface files?

    From 23a5f4f9558b685ab7b9fdd4e2c8710d58153164 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 17 Jun 2009 06:56:55 +0000 Subject: [PATCH 009/352] quote %include statements git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11283 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Arguments.html | 2 +- Doc/Manual/Ocaml.html | 4 ++-- Doc/Manual/Perl5.html | 4 ++-- Doc/Manual/Php.html | 6 +++--- Doc/Manual/Python.html | 2 +- Doc/Manual/Ruby.html | 2 +- Doc/Manual/Tcl.html | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Doc/Manual/Arguments.html b/Doc/Manual/Arguments.html index af8780452..911e8548e 100644 --- a/Doc/Manual/Arguments.html +++ b/Doc/Manual/Arguments.html @@ -351,7 +351,7 @@ function like this in an interface file :

     %module example
    -%include typemaps.i
    +%include "typemaps.i"
     ...
     %{
     extern void negate(double *);
    diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html
    index 6dbf24c11..b65831192 100644
    --- a/Doc/Manual/Ocaml.html
    +++ b/Doc/Manual/Ocaml.html
    @@ -634,13 +634,13 @@ length.  Instead, use multiple returns, as in the argout_ref example.
     #include "example.h"
     %}
     
    -%include stl.i
    +%include <stl.i>
     
     namespace std {
             %template(StringVector) std::vector < string >;
     };
     
    -%include example.h
    +%include "example.h"
     
    This example is in Examples/ocaml/stl diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 1dc8e7d2f..f77dc2f01 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -264,7 +264,7 @@ extern int fact(int); %} // Include code for rebuilding Perl -%include perlmain.i +%include <perlmain.i>

    @@ -1543,7 +1543,7 @@ example:

     %module example
    -%include typemaps.i
    +%include "typemaps.i"
     
     void add(int x, int y, int *REFERENCE);
     
    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 6e87a29a2..ab2c73f6c 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -479,7 +479,7 @@ One can include cpointer.i to generate PHP wrappers to int
     %module example
    -%include cpointer.i
    +%include "cpointer.i"
     %pointer_functions(int,intp)
     
     void add( int *in1, int *in2, int *result);
    @@ -513,7 +513,7 @@ parameter names as appropriate.
     
     
     %module example
    -%include typemaps.i
    +%include "typemaps.i"
     
     void add( int *INPUT, int *INPUT, int *OUTPUT);
     
    @@ -545,7 +545,7 @@ named typemap REFERENCE.
     
     
     %module example
    -%include phppointers.i
    +%include "phppointers.i"
     
     void add( int *REF, int *REF, int *REF);
     
    diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
    index f4867b69d..cfc035f00 100644
    --- a/Doc/Manual/Python.html
    +++ b/Doc/Manual/Python.html
    @@ -433,7 +433,7 @@ extern int mod(int, int);
     extern double My_variable;
     %}
     
    -%include embed.i       // Include code for a static version of Python
    +%include "embed.i"       // Include code for a static version of Python
     
     
    diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 2070db0c0..98fa315d0 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -2393,7 +2393,7 @@ intset;
    -%include std_set.i
    +%include <std_set.i>
    diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index b36395cab..04959de5f 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -190,7 +190,7 @@ extern int mod(int, int); extern double My_variable; %} -%include tclsh.i // Include code for rebuilding tclsh +%include "tclsh.i" // Include code for rebuilding tclsh
    @@ -2822,7 +2822,7 @@ int print_args(char **argv) { return i; } %} -%include tclsh.i +%include "tclsh.i"
    From 1a2e3a6653e225e6dbddddf9c70e03b78020f032 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Jun 2009 22:36:39 +0000 Subject: [PATCH 010/352] add further clarification about modules git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11285 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 1 + Doc/Manual/Modules.html | 55 ++++++++++++++++++++++++++++++++++------ Doc/Manual/SWIG.html | 19 +++++--------- 3 files changed, 54 insertions(+), 21 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index c135b7c6f..e997e46cb 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -488,6 +488,7 @@
      +
    • Modules Introduction
    • Basics
    • The SWIG runtime code
    • External access to the runtime diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 5ac66dc2e..6e1592d16 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -10,6 +10,7 @@
        +
      • Modules Introduction
      • Basics
      • The SWIG runtime code
      • External access to the runtime @@ -22,11 +23,48 @@ +

        15.1 Modules Introduction

        + + +

        +Each invocation of SWIG requires a module name to be specified. +The module name is used to name the resulting target language extension module. +Exactly what this means and and what the name is used for +depends on the target language, for example the name can define +a target language namespace or merely be a useful name for naming files or helper classes. +

        + +

        +The module name can be supplied in one of two ways. +The first is to specify it with the special %module +directive. This directive must appear at the beginning of the interface file. +The general form of this directive is: +

        + +
        +%module(option1="value1",option2="value2",...) modulename
        +
        + +

        +where the modulename is mandatory and the options add one or more optional additional features. +Typically no options are specified, for example: +

        + +
        +%module mymodule
        +
        + +

        +The second way to specify the module name is with the -module command line option, for example -module mymodule. +If the module name is supplied on the command line, it overrides the name specified by the +%module directive. +

        +

        When first working with SWIG, users commonly start by creating a single module. That is, you might define a single SWIG interface that wraps some set of C/C++ code. You then compile all of the generated -wrapper code into a module and use it. For large applications, however, +wrapper code together and use it. For large applications, however, this approach is problematic---the size of the generated wrapper code can be rather large. Moreover, it is probably easier to manage the target language interface when it is broken up into smaller pieces. @@ -34,10 +72,11 @@ target language interface when it is broken up into smaller pieces.

        This chapter describes the problem of using SWIG in programs -where you want to create a collection of modules. +where you want to create a collection of modules. +Each module in the collection is created via separate invocations of SWIG.

        -

        15.1 Basics

        +

        15.2 Basics

        @@ -135,7 +174,7 @@ in parallel from multiple threads as SWIG provides no locking - for more on that issue, read on.

        -

        15.2 The SWIG runtime code

        +

        15.3 The SWIG runtime code

        @@ -201,7 +240,7 @@ can peacefully coexist. So the type structures are separated by the is empty. Only modules compiled with the same pair will share type information.

        -

        15.3 External access to the runtime

        +

        15.4 External access to the runtime

        As described in The run-time type checker, @@ -238,7 +277,7 @@ SWIG_TYPE_TABLE to be the same as the module whose types you are trying to access.

        -

        15.4 A word of caution about static libraries

        +

        15.5 A word of caution about static libraries

        @@ -249,7 +288,7 @@ into it. This is very often NOT what you want and it can lead to unexpect behavior. When working with dynamically loadable modules, you should try to work exclusively with shared libraries.

        -

        15.5 References

        +

        15.6 References

        @@ -257,7 +296,7 @@ Due to the complexity of working with shared libraries and multiple modules, it an outside reference. John Levine's "Linkers and Loaders" is highly recommended.

        -

        15.6 Reducing the wrapper file size

        +

        15.7 Reducing the wrapper file size

        diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 3cbd3cf21..1bdc6b4d0 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -174,15 +174,8 @@ int bar(int x); ...

      -The name of the module is supplied using the special %module -directive (or the -module command line option). This -directive must appear at the beginning of the file and is used to name -the resulting target language extension module. Exactly what this results -in depends on the target language, eg the module name can define -a target language namespace or merely be a useful name for naming files or helper classes. -If the module name is supplied on the -command line, it overrides the name specified with the -%module directive. +The module name is supplied using the special %module +directive. Modules are described further in the Modules Introduction section.

      @@ -2889,12 +2882,12 @@ source/header file.

    • Make sure all necessary `typedef' declarations and type-information is available in the interface file. -In particular, ensure that the type information is specified in the correct order as required by a C compiler. -In particular, define a type before it is used! A C compiler will tell you -if the full type information is not available when it is needed, whereas +In particular, ensure that the type information is specified in the correct order as required by a C/C++ compiler. +Most importantly, define a type before it is used! A C compiler will tell you +if the full type information is not available if it is needed, whereas SWIG will usually not warn or error out as it is designed to work without full type information. However, if type information is not specified -correctly, the wrappers can be sub-optimal. +correctly, the wrappers can be sub-optimal and even result in uncompileable C/C++ code.
    • If your program has a main() function, you may need to rename it (read on). From 421a4419f2463bdb7c79ae887ce760a44121ea8d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 20 Jun 2009 00:32:49 +0000 Subject: [PATCH 011/352] a bit more on what is in a module git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11287 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Modules.html | 1 + 1 file changed, 1 insertion(+) diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 6e1592d16..1b628f802 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -32,6 +32,7 @@ The module name is used to name the resulting target language extension module. Exactly what this means and and what the name is used for depends on the target language, for example the name can define a target language namespace or merely be a useful name for naming files or helper classes. +Essentially, a module comprises target language wrappers for a chosen collection of global variables/functions, structs/classes and other C/C++ types.

      From 5d3deb2db19f23a0d37dc207bc983e4f37afbfc9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 24 Jun 2009 17:20:17 +0000 Subject: [PATCH 012/352] Fixes for compactdefaultargs and pass by value where the class being passed by value has no default constructor - previously it used SwigValueWrapper git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11312 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++++ Examples/test-suite/default_args.i | 2 ++ Source/Swig/cwrap.c | 6 +++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 822d2feed..d5b0062be 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.40 (in progress) ============================ +2009-06-24: wsfulton + Fix wrapping methods with default arguments and the compactdefaultargs feature + where a class is passed by value and is assigned a default value. The SwigValueWrapper + template workaround for a missing default constructor is no longer used as the code + generated does not call the default constructor. + 2009-06-16: wsfulton [Java,C#] Fix enum marshalling when %ignore is used on one of the enum items. Incorrect enum values were being passed to the C++ layer or compilation errors resulted. diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i index 69c90e2e6..839d28e3e 100644 --- a/Examples/test-suite/default_args.i +++ b/Examples/test-suite/default_args.i @@ -119,6 +119,7 @@ // tests valuewrapper +%feature("compactdefaultargs") MyClass2::set; %inline %{ enum MyType { Val1, Val2 }; @@ -134,6 +135,7 @@ 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) {} }; %} diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 7c6837a2b..121ea150a 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -195,7 +195,11 @@ int Swig_cargs(Wrapper *w, ParmList *p) { String *type = Getattr(p, "type"); /* default values only emitted if in compact default args mode */ String *pvalue = (compactdefargs) ? Getattr(p, "value") : 0; - SwigType *altty = SwigType_alttype(type, 0); + + /* When using compactdefaultargs, the code generated initialises a variable via a constructor call that accepts the + * default value as a parameter. The default constructor is not called and therefore SwigValueWrapper is not needed. */ + SwigType *altty = pvalue ? 0 : SwigType_alttype(type, 0); + int tycode = SwigType_type(type); if (tycode == T_REFERENCE) { if (pvalue) { From c7d90e58d80e0ad5efe9d6c5fac6d5b2d96a3ca7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 25 Jun 2009 06:01:11 +0000 Subject: [PATCH 013/352] improve some director warning messages git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11316 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 22 ++++++++++++++-------- Source/Modules/java.cxx | 38 ++++++++++++++++++++++++-------------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index ad6830ec6..82abc4803 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3332,7 +3332,8 @@ public: Delete(jretval_decl); } } else { - Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s\n", SwigType_str(returntype, 0)); + Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } @@ -3475,11 +3476,13 @@ public: Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number, "No cstype typemap defined for %s\n", SwigType_str(pt, 0)); } } else { - Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number, "No csdirectorin typemap defined for %s\n", SwigType_str(pt, 0)); + Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number, "No csdirectorin typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } } else { - Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(pt, 0)); + Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } @@ -3489,11 +3492,13 @@ public: } else { if (!desc_tm) { Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number, - "No or improper directorin typemap defined for %s\n", SwigType_str(c_param_type, 0)); + "No or improper directorin typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(c_param_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); p = nextSibling(p); } else if (!tm) { Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number, - "No or improper directorin typemap defined for argument %s\n", SwigType_str(pt, 0)); + "No or improper directorin typemap defined for argument %s for use in %s::%s (skipping director method)\n", + SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); p = nextSibling(p); } @@ -3502,7 +3507,8 @@ public: Delete(tp); } else { - Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s\n", SwigType_str(pt, 0)); + Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; p = nextSibling(p); } @@ -3602,8 +3608,8 @@ public: Printf(w->code, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, - "Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(returntype, 0), - SwigType_namestr(c_classname), SwigType_namestr(name)); + "Unable to use return type %s used in %s::%s (skipping director method)\n", + SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 50ef506ed..4f393b839 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -3387,7 +3387,8 @@ public: Append(classret_desc, jnidesc_canon); Delete(jnidesc_canon); } else { - Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "No or improper directorin typemap defined for %s\n", SwigType_str(returntype, 0)); + Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, "No or improper directorin typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } @@ -3418,13 +3419,15 @@ public: Delete(jnidesc_canon); } else { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, - "No or improper directorin typemap defined for %s\n", SwigType_str(c_ret_type, 0)); + "No or improper directorin typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(c_ret_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } Delete(tp); } else { - Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s\n", SwigType_str(returntype, 0)); + Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } @@ -3508,8 +3511,8 @@ public: Delete(tm); } else { Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, - "No or improper directorin typemap for type %s used in director method %s::%s\n", SwigType_str(type, 0), SwigType_namestr(c_classname), - SwigType_namestr(name)); + "No or improper directorin typemap for type %s for use in %s::%s (skipping director method)\n", + SwigType_str(type, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } @@ -3595,11 +3598,13 @@ public: Append(classdesc, jni_canon); Delete(jni_canon); } else { - Swig_warning(WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF, input_file, line_number, "No javadirectorin typemap defined for %s\n", SwigType_str(pt, 0)); + Swig_warning(WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF, input_file, line_number, "No javadirectorin typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } } else { - Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s\n", SwigType_str(pt, 0)); + Swig_warning(WARN_JAVA_TYPEMAP_JTYPE_UNDEF, input_file, line_number, "No jtype typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } @@ -3609,19 +3614,23 @@ public: } else { if (!desc_tm) { Swig_warning(WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF, input_file, line_number, - "No or improper directorin typemap defined for %s\n", SwigType_str(c_param_type, 0)); + "No or improper directorin typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(c_param_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); p = nextSibling(p); } else if (!jdesc) { Swig_warning(WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC, input_file, line_number, - "Missing JNI descriptor in directorin typemap defined for %s\n", SwigType_str(c_param_type, 0)); + "Missing JNI descriptor in directorin typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(c_param_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); p = Getattr(p, "tmap:directorin:next"); } else if (!tm) { Swig_warning(WARN_JAVA_TYPEMAP_JAVADIRECTORIN_UNDEF, input_file, line_number, - "No or improper directorin typemap defined for argument %s\n", SwigType_str(pt, 0)); + "No or improper directorin typemap defined for argument %s for use in %s::%s (skipping director method)\n", + SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); p = nextSibling(p); } else if (!cdesc) { Swig_warning(WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC, input_file, line_number, - "Missing JNI descriptor in directorin typemap defined for %s\n", SwigType_str(pt, 0)); + "Missing JNI descriptor in directorin typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); p = Getattr(p, "tmap:directorin:next"); } @@ -3630,7 +3639,8 @@ public: Delete(tp); } else { - Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s\n", SwigType_str(pt, 0)); + Swig_warning(WARN_JAVA_TYPEMAP_JNI_UNDEF, input_file, line_number, "No jni typemap defined for %s for use in %s::%s (skipping director method)\n", + SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; p = nextSibling(p); } @@ -3742,8 +3752,8 @@ public: Printf(w->code, "%s\n", tm); } else { Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, - "Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(returntype, 0), - SwigType_namestr(c_classname), SwigType_namestr(name)); + "Unable to use return type %s used in %s::%s (skipping director method)\n", + SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name)); output_director = false; } From 75198b86bf430b4f5a75bfe6189f41ed1af34e06 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 25 Jun 2009 06:05:06 +0000 Subject: [PATCH 014/352] update email address for Joseph Wang git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11317 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 3df9e506a..179b3ff56 100644 --- a/README +++ b/README @@ -20,7 +20,7 @@ Active Developers: Olly Betts (olly@survex.com) (PHP) John Lenz (Guile, MzScheme updates, Chicken module, runtime system) Mark Gossage (mark@gossage.cjb.net) (Lua) - Joseph Wang (joe@gnacademy.org) (R) + Joseph Wang (joequant@gmail.com) (R) Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL) Xavier Delacour (xavier.delacour@gmail.com) (Octave) From 45611ebd57b4ada25dfe25f064393b32ea77c48c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 26 Jun 2009 01:49:33 +0000 Subject: [PATCH 015/352] [Ruby] Fix to handle FIXNUM values greater than MAXINT passed for a double parameter. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11320 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/ruby/primitive_types_runme.rb | 3 +++ Lib/ruby/rubyprimtypes.swg | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index d5b0062be..609e04010 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-06-26: olly + [Ruby] Fix to handle FIXNUM values greater than MAXINT passed for a + double parameter. + 2009-06-24: wsfulton Fix wrapping methods with default arguments and the compactdefaultargs feature where a class is passed by value and is assigned a default value. The SwigValueWrapper diff --git a/Examples/test-suite/ruby/primitive_types_runme.rb b/Examples/test-suite/ruby/primitive_types_runme.rb index 9fde5b3dd..0024c9696 100644 --- a/Examples/test-suite/ruby/primitive_types_runme.rb +++ b/Examples/test-suite/ruby/primitive_types_runme.rb @@ -50,6 +50,9 @@ 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 diff --git a/Lib/ruby/rubyprimtypes.swg b/Lib/ruby/rubyprimtypes.swg index c2d577995..9e6c361ad 100644 --- a/Lib/ruby/rubyprimtypes.swg +++ b/Lib/ruby/rubyprimtypes.swg @@ -197,7 +197,7 @@ SWIG_AsVal_dec(unsigned long long)(VALUE obj, unsigned long long *val) } %fragment(SWIG_AsVal_frag(double),"header",fragment="SWIG_ruby_failed") { -%ruby_aux_method(double, NUM2DBL, (type == T_FLOAT ? NUM2DBL(obj) : (type == T_FIXNUM ? (double) FIX2INT(obj) : rb_big2dbl(obj)))) +%ruby_aux_method(double, NUM2DBL, NUM2DBL(obj)) SWIGINTERN int SWIG_AsVal_dec(double)(VALUE obj, double *val) From db8d65240734286f0b0065a76abecb9a7dab3881 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 26 Jun 2009 23:11:27 +0000 Subject: [PATCH 016/352] remove junk from Octave C example compilation command line options git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11324 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index d6dbfdeeb..8fab7a25d 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -335,12 +335,13 @@ 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) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE) - $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES) $(OCTAVE_INCLUDE) + $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE) + $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) # ----------------------------------------------------------------- From 4e1763ba69b3e3b43ec09f99104e0f9a0a99b62e Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 30 Jun 2009 11:50:14 +0000 Subject: [PATCH 017/352] [Ruby] Undefine close and connect macros defined by Ruby API headers as we don't need them and they can clash with C++ methods being wrapped. Patch from Vit Ondruch in SF#2814430. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11333 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 7 ++++++- Lib/ruby/rubyhead.swg | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 609e04010..730cefc04 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.40 (in progress) ============================ +2009-06-30: olly + [Ruby] Undefine close and connect macros defined by Ruby API + headers as we don't need them and they can clash with C++ methods + being wrapped. Patch from Vit Ondruch in SF#2814430. + 2009-06-26: olly [Ruby] Fix to handle FIXNUM values greater than MAXINT passed for a double parameter. @@ -17,7 +22,7 @@ Version 1.3.40 (in progress) 2009-06-02: talby [Perl] Resolved reference.i overload support problem - identfied by John Potowsky. + identified by John Potowsky. 2009-05-26: wsfulton [C#] Improved std::map wrappers based on patch from Yuval Baror. The C# proxy diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg index d17fdbaae..4b425dfd8 100644 --- a/Lib/ruby/rubyhead.swg +++ b/Lib/ruby/rubyhead.swg @@ -10,6 +10,12 @@ #ifdef bind # undef bind #endif +#ifdef close +# undef close +#endif +#ifdef connect +# undef connect +#endif /* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ From 3c39833584964091c6611c2fcd29ab88cd2360e2 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 30 Jun 2009 12:24:49 +0000 Subject: [PATCH 018/352] Use -O2 in the GCC examples as GCC defaults to not optimising at all. Document using GCC's -fPIC option as the standard approach - x86 is the oddity here and most architectures require it (or are always PIC), and on x86 it's better to use it or else code pages from the library need relocations and can't be shared. Use "python2.5" rather than "python2.0" in paths in example commands. Fix a typo. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11334 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Python.html | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index cfc035f00..8b359bda9 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -339,7 +339,7 @@ python that you run the command with. Taking apart the command line: setup.py is the tradition)

    • build_ext -- telling distutils to build extensions
    • --inplace -- this tells distutils to put the extension lib in the current dir. - Other wise, it will put it inside a build hierarchy, and you'd have to move it to use it. + Otherwise, it will put it inside a build hierarchy, and you'd have to move it to use it.

    @@ -363,8 +363,8 @@ program using commands like this (shown for Linux):

     $ swig -python example.i
    -$ gcc -c -fPIC example.c
    -$ gcc -c -fPIC example_wrap.c -I/usr/local/include/python2.0
    +$ gcc -O2 -fPIC -c example.c
    +$ gcc -O2 -fPIC -c example_wrap.c -I/usr/local/include/python2.5
     $ gcc -shared example.o example_wrap.o -o _example.so
     
    @@ -654,26 +654,19 @@ compiler. For example:
     $ swig -c++ -python example.i
    -$ g++ -c example.cxx
    -$ g++ -c example_wrap.cxx -I/usr/local/include/python2.0
    +$ g++ -O2 -fPIC -c example.cxx
    +$ g++ -O2 -fPIC -c example_wrap.cxx -I/usr/local/include/python2.5
     $ g++ -shared example.o example_wrap.o -o _example.so
     

    -On some platforms, you could also need to generate -position-independent code (PIC), by using a compiler option such as -fPIC. -Notably, the x86_64 (Opteron and EM64T) platform requires it, and when -using the GNU Compiler Suite, you will need to modify the previous example -as follows: +The -fPIC option tells GCC to generate position-independent code (PIC) +which is required for most architectures (it's not vital on x86, but +still a good idea as it allows code pages from the library to be shared between +processes). Other compilers may need a different option specified instead of +-fPIC.

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

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

     $ swig -c++ -python example.i
     $ CC -c example.cxx
    -$ CC -c example_wrap.cxx -I/usr/local/include/python2.0
    +$ CC -c example_wrap.cxx -I/usr/local/include/python2.5
     $ CC -G example.o example_wrap.o -L/opt/SUNWspro/lib -o _example.so -lCrun
     
    From 06346ca98b2f8b3bcaf74c24eff1476549762bc5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 Jul 2009 06:37:43 +0000 Subject: [PATCH 019/352] Update a few APIs which have changed over time git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11341 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Extending.html | 59 ++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 73f1a6673..0ebaeaa04 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -1025,7 +1025,7 @@ Deletes s.

    -int Len(String_or_char *s) +int Len(const String_or_char *s)

    @@ -1033,7 +1033,7 @@ Returns the length of the string.

    -char *Char(String_or_char *s) +char *Char(const String_or_char *s)

    @@ -1041,7 +1041,7 @@ Returns a pointer to the first character in a string.

    -void Append(String *s, String_or_char *t) +void Append(String *s, const String_or_char *t)

    @@ -1049,7 +1049,7 @@ Appends t to the end of string s.

    -void Insert(String *s, int pos, String_or_char *t) +void Insert(String *s, int pos, const String_or_char *t)

    @@ -1162,7 +1162,7 @@ Returns the number of items in h.

    -Object *Getattr(Hash *h, String_or_char *key) +Object *Getattr(Hash *h, const String_or_char *key)

    @@ -1171,7 +1171,7 @@ a simple char * string. Returns NULL if not found.

    -int Setattr(Hash *h, String_or_char *key, Object_or_char *val) +int Setattr(Hash *h, const String_or_char *key, const Object_or_char *val)

    @@ -1185,7 +1185,7 @@ of val. Returns 1 if this operation replaced an existing hash entry,

    -int Delattr(Hash *h, String_or_char *key) +int Delattr(Hash *h, const String_or_char *key)

    @@ -1249,7 +1249,7 @@ negative, the first item is returned.

    -int *Setitem(List *x, int n, Object_or_char *val) +int *Setitem(List *x, int n, const Object_or_char *val)

    @@ -1271,7 +1271,7 @@ for n.

    -void Append(List *x, Object_or_char *t) +void Append(List *x, const Object_or_char *t)

    @@ -1281,7 +1281,7 @@ used to create a String object.

    -void Insert(String *s, int pos, Object_or_char *t) +void Insert(String *s, int pos, const Object_or_char *t)

    @@ -1479,13 +1479,14 @@ Same as the C tell() function.

    -File *NewFile(const char *filename, const char *mode) +File *NewFile(const char *filename, const char *mode, List *newfiles)

    Create a File object using the fopen() library call. This file differs from FILE * in that it can be placed in the standard -SWIG containers (lists, hashes, etc.). +SWIG containers (lists, hashes, etc.). The filename is added to the +newfiles list if newfiles is non-zero and the file was created successfully.

    @@ -1922,7 +1923,7 @@ Adds a reference to ty.

    -void SwigType_add_array(SwigType *ty, String_or_char *dim) +void SwigType_add_array(SwigType *ty, const String_or_char *size)

    @@ -1962,7 +1963,7 @@ Sets nth array dimensions of ty to rep.

    -void SwigType_add_qualifier(SwigType *ty, String_or_char *q) +void SwigType_add_qualifier(SwigType *ty, const String_or_char *q)

    @@ -1971,7 +1972,7 @@ Adds a type qualifier q to ty. q is typically

    -void SwigType_add_memberpointer(SwigType *ty, String_or_char *cls) +void SwigType_add_memberpointer(SwigType *ty, const String_or_char *cls)

    @@ -2292,7 +2293,7 @@ The following functions produce strings that are suitable for output.

    -String *SwigType_str(SwigType *ty, String_or_char *id = 0) +String *SwigType_str(SwigType *ty, const String_or_char *id = 0)

    @@ -2303,7 +2304,7 @@ used to convert string-encoded types back into a form that is valid C syntax.

    -String *SwigType_lstr(SwigType *ty, String_or_char *id = 0) +String *SwigType_lstr(SwigType *ty, const String_or_char *id = 0)

    @@ -2312,7 +2313,7 @@ is generated from the type's lvalue (as generated from SwigType_ltype).

    -String *SwigType_lcaststr(SwigType *ty, String_or_char *id = 0) +String *SwigType_lcaststr(SwigType *ty, const String_or_char *id = 0)

    @@ -2323,7 +2324,7 @@ this function produces the string "(char *) foo".

    -String *SwigType_rcaststr(SwigType *ty, String_or_char *id = 0) +String *SwigType_rcaststr(SwigType *ty, const String_or_char *id = 0)

    @@ -2776,6 +2777,7 @@ such as: class PYTHON : public Language { protected: /* General DOH objects used for holding the strings */ + File *f_begin; File *f_runtime; File *f_header; File *f_wrappers; @@ -2791,22 +2793,25 @@ int Python::top(Node *n) { ... /* Initialize I/O */ - f_runtime = NewFile(outfile, "w"); - if (!f_runtime) { + f_begin = NewFile(outfile, "w", SWIG_output_files()); + if (!f_begin) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } + f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); /* Register file targets with the SWIG file handler */ + Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); /* Output module initialization code */ + Swig_banner(f_begin); ... /* Emit code for children */ @@ -2814,16 +2819,18 @@ int Python::top(Node *n) { ... /* Write all to the file */ - Dump(f_header, f_runtime); - Dump(f_wrappers, f_runtime); - Wrapper_pretty_print(f_init, f_runtime); + Dump(f_runtime, f_begin); + Dump(f_header, f_begin); + Dump(f_wrappers, f_begin); + Wrapper_pretty_print(f_init, f_begin); /* Cleanup files */ + Delete(f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_runtime); - Delete(f_runtime); + Close(f_begin); + Delete(f_begin); return SWIG_OK; } From 3dbca3bd05c779ec9d46f2141142d6be07468af8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 Jul 2009 18:25:04 +0000 Subject: [PATCH 020/352] Fix syntax error when a nested struct contains a comment containing a * followed eventually by a / git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11344 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/nested_comment.i | 2 +- Source/CParse/parser.y | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 730cefc04..de8203538 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-07-02: wsfulton + Fix syntax error when a nested struct contains a comment containing a * followed eventually by a /. + Regression from 1.3.37, reported by Solomon Gibbs. + 2009-06-30: olly [Ruby] Undefine close and connect macros defined by Ruby API headers as we don't need them and they can clash with C++ methods diff --git a/Examples/test-suite/nested_comment.i b/Examples/test-suite/nested_comment.i index ea365a6fe..a9948eb0f 100644 --- a/Examples/test-suite/nested_comment.i +++ b/Examples/test-suite/nested_comment.i @@ -27,7 +27,7 @@ struct a struct { /*struct*/ struct { - int b; + int b; /**< v1/v2 B-tree & local/fractal heap for groups, B-tree for chunked datasets */ } c; } d; }; diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 0babfbbb8..11232fd78 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1054,6 +1054,8 @@ static void strip_comments(char *string) { case 5: if (*c == '/') state = 0; + else + state = 1; *c = ' '; break; case 6: From 481fead9fc1ad89d679f6ffc4d4ffce9f1729f29 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 Jul 2009 18:28:50 +0000 Subject: [PATCH 021/352] Fix -Wallkw commandline option git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11345 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/allkw.swg | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index de8203538..8661489a0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.40 (in progress) ============================ +2009-07-02: wsfulton + Fix -Wallkw option as reported by Solomon Gibbs. + 2009-07-02: wsfulton Fix syntax error when a nested struct contains a comment containing a * followed eventually by a /. Regression from 1.3.37, reported by Solomon Gibbs. diff --git a/Lib/allkw.swg b/Lib/allkw.swg index 2a2fe18d8..fb76ff287 100644 --- a/Lib/allkw.swg +++ b/Lib/allkw.swg @@ -19,7 +19,7 @@ %include %include %include -%include +%include %include %include %include From 7db0c01af04a5b2bf6a92c2425feede2293f161f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 Jul 2009 20:32:51 +0000 Subject: [PATCH 022/352] rename byreference testcase to li_reference to follow normal test naming conventions of library files. Remove ability to add testcases into subdirectories (again) - not wanted git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11346 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 +- .../{perl5/byreference.i => li_reference.i} | 2 +- Examples/test-suite/perl5/Makefile.in | 2 +- .../test-suite/perl5/byreference_runme.pl | 36 ------------------- .../test-suite/perl5/li_reference_runme.pl | 36 +++++++++++++++++++ 5 files changed, 39 insertions(+), 39 deletions(-) rename Examples/test-suite/{perl5/byreference.i => li_reference.i} (99%) delete mode 100644 Examples/test-suite/perl5/byreference_runme.pl create mode 100644 Examples/test-suite/perl5/li_reference_runme.pl diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 753c5fbdf..5c6a332a4 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -64,7 +64,7 @@ INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) LIBS = -L. LIBPREFIX = lib ACTION = check -INTERFACEDIR = $(if $(wildcard $*.i), ./, ../) +INTERFACEDIR = ../ # # Please keep test cases in alphabetical order. diff --git a/Examples/test-suite/perl5/byreference.i b/Examples/test-suite/li_reference.i similarity index 99% rename from Examples/test-suite/perl5/byreference.i rename to Examples/test-suite/li_reference.i index 43215f1cc..d021e807f 100644 --- a/Examples/test-suite/perl5/byreference.i +++ b/Examples/test-suite/li_reference.i @@ -1,4 +1,4 @@ -%module byreference +%module li_reference %include "reference.i" diff --git a/Examples/test-suite/perl5/Makefile.in b/Examples/test-suite/perl5/Makefile.in index 518d341b2..97079fa75 100644 --- a/Examples/test-suite/perl5/Makefile.in +++ b/Examples/test-suite/perl5/Makefile.in @@ -15,7 +15,7 @@ CPP_TEST_CASES += \ li_cdata \ li_cstring \ li_cdata_carrays \ - byreference \ + li_reference \ C_TEST_CASES += \ li_cdata \ diff --git a/Examples/test-suite/perl5/byreference_runme.pl b/Examples/test-suite/perl5/byreference_runme.pl deleted file mode 100644 index 845d870cd..000000000 --- a/Examples/test-suite/perl5/byreference_runme.pl +++ /dev/null @@ -1,36 +0,0 @@ -use strict; -use warnings; -use Test::More tests => 68; -BEGIN { use_ok('byreference') } -require_ok('byreference'); - -sub chk { my($type, $call, $v1, $v2) = @_; - $byreference::FrVal = $v1; - my $v = $v2; - eval { $call->(\$v) }; - is($@, '', "$type check"); - is($byreference::ToVal, $v2, "$type out"); - is($v, $v1, "$type in"); -} -chk("double*", \&byreference::PDouble, 12.2, 18.6); -chk("double&", \&byreference::RDouble, 32.5, 64.8); -chk("float*", \&byreference::PFloat, 64.5, 96.0); -chk("float&", \&byreference::RFloat, 98.5, 6.25); -chk("int*", \&byreference::PInt, 1887, 3356); -chk("int&", \&byreference::RInt, 2622, 9867); -chk("short*", \&byreference::PShort, 4752, 3254); -chk("short&", \&byreference::RShort, 1898, 5757); -chk("long*", \&byreference::PLong, 6687, 7132); -chk("long&", \&byreference::RLong, 8346, 4398); -chk("uint*", \&byreference::PUInt, 6853, 5529); -chk("uint&", \&byreference::RUInt, 5483, 7135); -chk("ushort*", \&byreference::PUShort, 9960, 9930); -chk("ushort&", \&byreference::RUShort, 1193, 4178); -chk("ulong*", \&byreference::PULong, 7960, 4788); -chk("ulong&", \&byreference::RULong, 8829, 1603); -chk("uchar*", \&byreference::PUChar, 110, 239); -chk("uchar&", \&byreference::RUChar, 15, 97); -chk("char*", \&byreference::PChar, -7, 118); -chk("char&", \&byreference::RChar, -3, -107); -chk("bool*", \&byreference::PBool, 0, 1); -chk("bool&", \&byreference::RBool, 1, 0); diff --git a/Examples/test-suite/perl5/li_reference_runme.pl b/Examples/test-suite/perl5/li_reference_runme.pl new file mode 100644 index 000000000..afbd9e088 --- /dev/null +++ b/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); From 134610e55dadf3f9b4789e39caea4d61f9b6ddde Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 Jul 2009 21:35:41 +0000 Subject: [PATCH 023/352] Add a test for the -Wallkw commandline option. Also refine general framework for using custom commandline options for individual test cases git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11347 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 19 +++++++++++--- Examples/test-suite/csharp/Makefile.in | 6 ++--- .../test-suite/java/custom_wallkw_runme.java | 25 +++++++++++++++++++ 3 files changed, 43 insertions(+), 7 deletions(-) create mode 100644 Examples/test-suite/java/custom_wallkw_runme.java diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 5c6a332a4..9b54765ef 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -60,6 +60,7 @@ CSRCS = TARGETPREFIX = TARGETSUFFIX = SWIGOPT = -outcurrentdir -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) +SWIGOPTCUSTOM = INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) LIBS = -L. LIBPREFIX = lib @@ -468,6 +469,16 @@ MULTI_CPP_TEST_CASES += \ template_typedef_import \ multi_import +# Non standard testcases, usually using custom commandline options +# Testcase names are prefixed with custom_ and can be run individually using make testcase.customtest +CUSTOM_TEST_CASES = \ + custom_allkw \ + +# individual custom tests - any kind of customisation allowed here +# Note: $(basename $@) strips everything after and including the . in the target name +custom_wallkw.customtest: + $(MAKE) $(basename $@).cpptest SWIGOPTCUSTOM="-Wallkw" + NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \ $(C_TEST_CASES:=.ctest) \ $(MULTI_CPP_TEST_CASES:=.multicpptest) \ @@ -500,14 +511,14 @@ 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 \ + INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $(SWIGOPTCUSTOM)" 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 \ + INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $(SWIGOPTCUSTOM)" NOLINK=true \ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT) @@ -515,7 +526,7 @@ 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 \ + INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $(SWIGOPTCUSTOM)" NOLINK=true \ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done @@ -527,7 +538,7 @@ swig_and_compile_external = \ $(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 \ + INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $(SWIGOPTCUSTOM)" NOLINK=true \ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 5fb547f3f..df5f1a7fd 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -28,7 +28,7 @@ CUSTOM_TEST_CASES = \ include $(srcdir)/../common.mk # Overridden variables here -SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL) +SWIGOPT += -namespace $*Namespace INTERFACEDIR = ../../ CSHARPFLAGSSPECIAL = @@ -51,9 +51,9 @@ CSHARPFLAGSSPECIAL = # Rules for custom tests intermediary_classname.customtest: - $(MAKE) intermediary_classname.cpptest SWIGOPTSPECIAL="-dllimport intermediary_classname" + $(MAKE) $(basename $@).cpptest SWIGOPTCUSTOM="-dllimport intermediary_classname" csharp_lib_arrays.customtest: - $(MAKE) csharp_lib_arrays.cpptest CSHARPFLAGSSPECIAL="-unsafe" + $(MAKE) $(basename $@).cpptest CSHARPFLAGSSPECIAL="-unsafe" # Makes a directory for the testcase if it does not exist setup = \ diff --git a/Examples/test-suite/java/custom_wallkw_runme.java b/Examples/test-suite/java/custom_wallkw_runme.java new file mode 100644 index 000000000..08d9539bd --- /dev/null +++ b/Examples/test-suite/java/custom_wallkw_runme.java @@ -0,0 +1,25 @@ + +import custom_wallkw.*; + +public class custom_wallkw_runme { + + static { + try { + System.loadLibrary("custom_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 (!custom_wallkw.c_clone().equals("clone")) + throw new RuntimeException("clone_c keyword fail"); + if (!custom_wallkw._delegate().equals("delegate")) + throw new RuntimeException("delegate keyword fail"); + if (!custom_wallkw._pass().equals("pass")) + throw new RuntimeException("pass keyword fail"); + if (!custom_wallkw.C_alias().equals("alias")) + throw new RuntimeException("alias keyword fail"); + } +} From 1adaae5780b5e3c264870f2977808f129d9ec605 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 2 Jul 2009 21:59:29 +0000 Subject: [PATCH 024/352] rename custom testcases with a custom_ prefix (intermediary_classname.i and lib_arrays.i). Also some typo fixes for custom testcases git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11348 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 7 ++++--- Examples/test-suite/csharp/Makefile.in | 10 +++++----- ...ys_runme.cs => custom_csharp_lib_arrays_runme.cs} | 10 +++++----- ...nme.cs => custom_intermediary_classname_runme.cs} | 10 +++++----- ...sharp_lib_arrays.i => custom_csharp_lib_arrays.i} | 2 +- ...y_classname.i => custom_intermediary_classname.i} | 2 +- Examples/test-suite/java/Makefile.in | 2 +- ...java => custom_intermediary_classname_runme.java} | 12 ++++++------ 8 files changed, 28 insertions(+), 27 deletions(-) rename Examples/test-suite/csharp/{csharp_lib_arrays_runme.cs => custom_csharp_lib_arrays_runme.cs} (77%) rename Examples/test-suite/csharp/{intermediary_classname_runme.cs => custom_intermediary_classname_runme.cs} (60%) rename Examples/test-suite/{csharp_lib_arrays.i => custom_csharp_lib_arrays.i} (97%) rename Examples/test-suite/{intermediary_classname.i => custom_intermediary_classname.i} (94%) rename Examples/test-suite/java/{intermediary_classname_runme.java => custom_intermediary_classname_runme.java} (58%) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 9b54765ef..744ffc1c3 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -9,7 +9,8 @@ # 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) +# MULTI_CPP_TEST_CASES (multi-module c++ tests) or +# CUSTOM_TEST_CASES (mainly for customised SWIG comandline options) # 2) If not already done, create a makefile which: # a) Defines LANGUAGE matching a language rule in Examples/Makefile, # for example LANGUAGE = java @@ -471,8 +472,8 @@ MULTI_CPP_TEST_CASES += \ # Non standard testcases, usually using custom commandline options # Testcase names are prefixed with custom_ and can be run individually using make testcase.customtest -CUSTOM_TEST_CASES = \ - custom_allkw \ +CUSTOM_TEST_CASES += \ + custom_wallkw \ # individual custom tests - any kind of customisation allowed here # Note: $(basename $@) strips everything after and including the . in the target name diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index df5f1a7fd..0c5ff5520 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -22,8 +22,8 @@ CPP_TEST_CASES = \ exception_partial_info CUSTOM_TEST_CASES = \ - csharp_lib_arrays \ - intermediary_classname + custom_csharp_lib_arrays \ + custom_intermediary_classname include $(srcdir)/../common.mk @@ -50,9 +50,9 @@ CSHARPFLAGSSPECIAL = +$(run_testcase) # Rules for custom tests -intermediary_classname.customtest: - $(MAKE) $(basename $@).cpptest SWIGOPTCUSTOM="-dllimport intermediary_classname" -csharp_lib_arrays.customtest: +custom_intermediary_classname.customtest: + $(MAKE) $(basename $@).cpptest SWIGOPTCUSTOM="-dllimport custom_intermediary_classname" +custom_csharp_lib_arrays.customtest: $(MAKE) $(basename $@).cpptest CSHARPFLAGSSPECIAL="-unsafe" # Makes a directory for the testcase if it does not exist diff --git a/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs b/Examples/test-suite/csharp/custom_csharp_lib_arrays_runme.cs similarity index 77% rename from Examples/test-suite/csharp/csharp_lib_arrays_runme.cs rename to Examples/test-suite/csharp/custom_csharp_lib_arrays_runme.cs index 9f3ea6b88..aa0cd0ede 100644 --- a/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs +++ b/Examples/test-suite/csharp/custom_csharp_lib_arrays_runme.cs @@ -1,5 +1,5 @@ using System; -using csharp_lib_arraysNamespace; +using custom_csharp_lib_arraysNamespace; public class runme { @@ -9,7 +9,7 @@ public class runme int[] source = { 1, 2, 3, 4, 5 }; int[] target = new int[ source.Length ]; - csharp_lib_arrays.myArrayCopy( source, target, target.Length ); + custom_csharp_lib_arrays.myArrayCopy( source, target, target.Length ); CompareArrays(source, target); } @@ -17,7 +17,7 @@ public class runme int[] source = { 1, 2, 3, 4, 5 }; int[] target = new int[ source.Length ]; - csharp_lib_arrays.myArrayCopyUsingFixedArrays( source, target, target.Length ); + custom_csharp_lib_arrays.myArrayCopyUsingFixedArrays( source, target, target.Length ); CompareArrays(source, target); } @@ -25,7 +25,7 @@ public class runme int[] source = { 1, 2, 3, 4, 5 }; int[] target = new int[] { 6, 7, 8, 9, 10 }; - csharp_lib_arrays.myArraySwap( source, target, target.Length ); + custom_csharp_lib_arrays.myArraySwap( source, target, target.Length ); for (int i=0; i Date: Thu, 2 Jul 2009 22:40:49 +0000 Subject: [PATCH 025/352] reverse merge last commit - 11348 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11349 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 7 +++---- Examples/test-suite/csharp/Makefile.in | 10 +++++----- ...ib_arrays_runme.cs => csharp_lib_arrays_runme.cs} | 10 +++++----- ...name_runme.cs => intermediary_classname_runme.cs} | 10 +++++----- ...ustom_csharp_lib_arrays.i => csharp_lib_arrays.i} | 2 +- ...rmediary_classname.i => intermediary_classname.i} | 2 +- Examples/test-suite/java/Makefile.in | 2 +- ..._runme.java => intermediary_classname_runme.java} | 12 ++++++------ 8 files changed, 27 insertions(+), 28 deletions(-) rename Examples/test-suite/csharp/{custom_csharp_lib_arrays_runme.cs => csharp_lib_arrays_runme.cs} (77%) rename Examples/test-suite/csharp/{custom_intermediary_classname_runme.cs => intermediary_classname_runme.cs} (60%) rename Examples/test-suite/{custom_csharp_lib_arrays.i => csharp_lib_arrays.i} (97%) rename Examples/test-suite/{custom_intermediary_classname.i => intermediary_classname.i} (94%) rename Examples/test-suite/java/{custom_intermediary_classname_runme.java => intermediary_classname_runme.java} (58%) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 744ffc1c3..9b54765ef 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -9,8 +9,7 @@ # 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) or -# CUSTOM_TEST_CASES (mainly for customised SWIG comandline options) +# 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 @@ -472,8 +471,8 @@ MULTI_CPP_TEST_CASES += \ # Non standard testcases, usually using custom commandline options # Testcase names are prefixed with custom_ and can be run individually using make testcase.customtest -CUSTOM_TEST_CASES += \ - custom_wallkw \ +CUSTOM_TEST_CASES = \ + custom_allkw \ # individual custom tests - any kind of customisation allowed here # Note: $(basename $@) strips everything after and including the . in the target name diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 0c5ff5520..df5f1a7fd 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -22,8 +22,8 @@ CPP_TEST_CASES = \ exception_partial_info CUSTOM_TEST_CASES = \ - custom_csharp_lib_arrays \ - custom_intermediary_classname + csharp_lib_arrays \ + intermediary_classname include $(srcdir)/../common.mk @@ -50,9 +50,9 @@ CSHARPFLAGSSPECIAL = +$(run_testcase) # Rules for custom tests -custom_intermediary_classname.customtest: - $(MAKE) $(basename $@).cpptest SWIGOPTCUSTOM="-dllimport custom_intermediary_classname" -custom_csharp_lib_arrays.customtest: +intermediary_classname.customtest: + $(MAKE) $(basename $@).cpptest SWIGOPTCUSTOM="-dllimport intermediary_classname" +csharp_lib_arrays.customtest: $(MAKE) $(basename $@).cpptest CSHARPFLAGSSPECIAL="-unsafe" # Makes a directory for the testcase if it does not exist diff --git a/Examples/test-suite/csharp/custom_csharp_lib_arrays_runme.cs b/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs similarity index 77% rename from Examples/test-suite/csharp/custom_csharp_lib_arrays_runme.cs rename to Examples/test-suite/csharp/csharp_lib_arrays_runme.cs index aa0cd0ede..9f3ea6b88 100644 --- a/Examples/test-suite/csharp/custom_csharp_lib_arrays_runme.cs +++ b/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs @@ -1,5 +1,5 @@ using System; -using custom_csharp_lib_arraysNamespace; +using csharp_lib_arraysNamespace; public class runme { @@ -9,7 +9,7 @@ public class runme int[] source = { 1, 2, 3, 4, 5 }; int[] target = new int[ source.Length ]; - custom_csharp_lib_arrays.myArrayCopy( source, target, target.Length ); + csharp_lib_arrays.myArrayCopy( source, target, target.Length ); CompareArrays(source, target); } @@ -17,7 +17,7 @@ public class runme int[] source = { 1, 2, 3, 4, 5 }; int[] target = new int[ source.Length ]; - custom_csharp_lib_arrays.myArrayCopyUsingFixedArrays( source, target, target.Length ); + csharp_lib_arrays.myArrayCopyUsingFixedArrays( source, target, target.Length ); CompareArrays(source, target); } @@ -25,7 +25,7 @@ public class runme int[] source = { 1, 2, 3, 4, 5 }; int[] target = new int[] { 6, 7, 8, 9, 10 }; - custom_csharp_lib_arrays.myArraySwap( source, target, target.Length ); + csharp_lib_arrays.myArraySwap( source, target, target.Length ); for (int i=0; i Date: Thu, 2 Jul 2009 22:42:45 +0000 Subject: [PATCH 026/352] fix typo in custom_wallkw testcase name git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11350 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 9b54765ef..f60da6cc6 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -472,7 +472,7 @@ MULTI_CPP_TEST_CASES += \ # Non standard testcases, usually using custom commandline options # Testcase names are prefixed with custom_ and can be run individually using make testcase.customtest CUSTOM_TEST_CASES = \ - custom_allkw \ + custom_wallkw \ # individual custom tests - any kind of customisation allowed here # Note: $(basename $@) strips everything after and including the . in the target name From 734dafd405a337d0ed7e134ccef1037732d61ad5 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 3 Jul 2009 11:58:37 +0000 Subject: [PATCH 027/352] Fix grammar in comment and error message. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11352 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/std_map.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index c93ffe61b..efe0e5e4c 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -23,8 +23,8 @@ if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); %#if PY_VERSION_HEX >= 0x03000000 - /* In Python 3.x the ".items()" method return a dict_items object */ - items = PySequence_Fast(items, ".items() havn't returned a sequence!"); + /* In Python 3.x the ".items()" method returns a dict_items object */ + items = PySequence_Fast(items, ".items() didn't return a sequence!"); %#endif res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { From 7f5586a370cd4a80a9990b4642f446023d31e2fe Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 3 Jul 2009 14:17:03 +0000 Subject: [PATCH 028/352] [Tcl] To complement USE_TCL_STUBS, add support for USE_TK_STUBS and SWIG_TCL_STUBS_VERSION. Document all three in the Tcl chapter of the manual. Based on patch from SF#2810380 by Christian Gollwitzer. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11353 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++++ Doc/Manual/Tcl.html | 22 ++++++++++++++++++++++ Lib/tcl/tclinit.swg | 15 ++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 8661489a0..f6906e0a3 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.40 (in progress) ============================ +2009-07-03: olly + [Tcl] To complement USE_TCL_STUBS, add support for USE_TK_STUBS + and SWIG_TCL_STUBS_VERSION. Document all three in the Tcl chapter + of the manual. Based on patch from SF#2810380 by Christian + Gollwitzer. + 2009-07-02: wsfulton Fix -Wallkw option as reported by Solomon Gibbs. diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index 04959de5f..2c02a9b34 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -66,6 +66,7 @@ +
  • Tcl/Tk Stubs @@ -3409,5 +3410,26 @@ short, but clever Tcl script can be combined with SWIG to do many interesting things.

    +

    33.10 Tcl/Tk Stubs

    + +

    +For background information about the Tcl Stubs feature, see +http://www.tcl.tk/doc/howto/stubs.html. +

    + +

    +As of SWIG 1.3.10, the generated C/C++ wrapper will use the Tcl Stubs +feature if compiled with -DUSE_TCL_STUBS. +

    + +

    +As of SWIG 1.3.40, the generated C/C++ wrapper will use the Tk Stubs +feature if compiled with -DUSE_TK_STUBS. Also, you can override +the minimum version to support which is passed to Tcl_InitStubs() +and Tk_InitStubs() with -DSWIG_TCL_STUBS_VERSION="8.3" +or the version being compiled with using +-DSWIG_TCL_STUBS_VERSION=TCL_VERSION. +

    + diff --git a/Lib/tcl/tclinit.swg b/Lib/tcl/tclinit.swg index 93d984ae2..6910d3c51 100644 --- a/Lib/tcl/tclinit.swg +++ b/Lib/tcl/tclinit.swg @@ -22,6 +22,11 @@ SWIGEXPORT int SWIG_init(Tcl_Interp *); } #endif +/* Compatibility version for TCL stubs */ +#ifndef SWIG_TCL_STUBS_VERSION +#define SWIG_TCL_STUBS_VERSION "8.1" +#endif + %} %init %{ @@ -74,10 +79,18 @@ SWIGEXPORT int SWIG_init(Tcl_Interp *interp) { int i; if (interp == 0) return TCL_ERROR; #ifdef USE_TCL_STUBS - if (Tcl_InitStubs(interp, (char*)"8.1", 0) == NULL) { + /* (char*) cast is required to avoid compiler warning/error for Tcl < 8.4. */ + if (Tcl_InitStubs(interp, (char*)SWIG_TCL_STUBS_VERSION, 0) == NULL) { return TCL_ERROR; } #endif +#ifdef USE_TK_STUBS + /* (char*) cast is required to avoid compiler warning/error. */ + if (Tk_InitStubs(interp, (char*)SWIG_TCL_STUBS_VERSION, 0) == NULL) { + return TCL_ERROR; + } +#endif + Tcl_PkgProvide(interp, (char*)SWIG_name, (char*)SWIG_version); #ifdef SWIG_namespace From 092073588de6e984eac5716c8fed99def15ff45b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 3 Jul 2009 21:23:34 +0000 Subject: [PATCH 029/352] add missed out test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11355 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/custom_wallkw.i | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Examples/test-suite/custom_wallkw.i diff --git a/Examples/test-suite/custom_wallkw.i b/Examples/test-suite/custom_wallkw.i new file mode 100644 index 000000000..1f4742a19 --- /dev/null +++ b/Examples/test-suite/custom_wallkw.i @@ -0,0 +1,16 @@ +%module custom_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"; } +%} + From 9064b086515b2d836c280243e0b23558b4c63866 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 3 Jul 2009 22:23:43 +0000 Subject: [PATCH 030/352] better way to provide custom commandline options for individual tests git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11356 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/allegrocl/Makefile.in | 4 +++ Examples/test-suite/cffi/Makefile.in | 4 +++ Examples/test-suite/chicken/Makefile.in | 4 ++- Examples/test-suite/clisp/Makefile.in | 4 +++ Examples/test-suite/common.mk | 36 +++++++++-------------- Examples/test-suite/csharp/Makefile.in | 16 ++++------ Examples/test-suite/guile/Makefile.in | 3 ++ Examples/test-suite/guilescm/Makefile.in | 5 +++- Examples/test-suite/java/Makefile.in | 3 ++ Examples/test-suite/lua/Makefile.in | 3 ++ Examples/test-suite/mzscheme/Makefile.in | 3 ++ Examples/test-suite/ocaml/Makefile.in | 3 ++ Examples/test-suite/octave/Makefile.in | 3 ++ Examples/test-suite/perl5/Makefile.in | 3 ++ Examples/test-suite/php/Makefile.in | 3 ++ Examples/test-suite/pike/Makefile.in | 3 ++ Examples/test-suite/python/Makefile.in | 3 ++ Examples/test-suite/r/Makefile.in | 4 +++ Examples/test-suite/ruby/Makefile.in | 6 ++-- Examples/test-suite/tcl/Makefile.in | 3 ++ Examples/test-suite/uffi/Makefile.in | 4 +++ 21 files changed, 82 insertions(+), 38 deletions(-) diff --git a/Examples/test-suite/allegrocl/Makefile.in b/Examples/test-suite/allegrocl/Makefile.in index df7193389..556c38238 100644 --- a/Examples/test-suite/allegrocl/Makefile.in +++ b/Examples/test-suite/allegrocl/Makefile.in @@ -89,8 +89,12 @@ 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) diff --git a/Examples/test-suite/cffi/Makefile.in b/Examples/test-suite/cffi/Makefile.in index c34519633..ac24688e3 100644 --- a/Examples/test-suite/cffi/Makefile.in +++ b/Examples/test-suite/cffi/Makefile.in @@ -11,10 +11,14 @@ 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) diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in index 764518880..a3a2566bb 100644 --- a/Examples/test-suite/chicken/Makefile.in +++ b/Examples/test-suite/chicken/Makefile.in @@ -23,10 +23,12 @@ EXTRA_TEST_CASES += chicken_ext_test.externaltest include $(srcdir)/../common.mk - # Overridden variables here SWIGOPT += -nounit +# Custom tests - tests with additional commandline options +# none! + # Rules for the different types of tests %.cpptest: $(setup) diff --git a/Examples/test-suite/clisp/Makefile.in b/Examples/test-suite/clisp/Makefile.in index 279ab97da..2139faaed 100644 --- a/Examples/test-suite/clisp/Makefile.in +++ b/Examples/test-suite/clisp/Makefile.in @@ -11,10 +11,14 @@ 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) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index f60da6cc6..dcc5da2bd 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -16,8 +16,8 @@ # 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 can be achieved by adding a -# test case to CUSTOM_TEST_CASES and defining rules to run and test. +# 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 @@ -60,7 +60,6 @@ CSRCS = TARGETPREFIX = TARGETSUFFIX = SWIGOPT = -outcurrentdir -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) -SWIGOPTCUSTOM = INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) LIBS = -L. LIBPREFIX = lib @@ -72,7 +71,7 @@ INTERFACEDIR = ../ # 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.) +# Broken C++ test cases. (Can be run individually using: make testcase.cpptest) CPP_TEST_BROKEN += \ constants \ cpp_broken \ @@ -86,12 +85,12 @@ CPP_TEST_BROKEN += \ template_expr -# Broken C test cases. (Can be run individually using make testcase.ctest.) +# 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.) +# C++ test cases. (Can be run individually using: make testcase.cpptest) CPP_TEST_CASES += \ abstract_access \ abstract_inherit \ @@ -143,6 +142,7 @@ CPP_TEST_CASES += \ cpp_nodefault \ cpp_static \ cpp_typedef \ + custom_wallkw \ default_args \ default_constructor \ defvalue_constructor \ @@ -421,7 +421,7 @@ CPP_TEST_CASES += ${CPP_STD_TEST_CASES} endif -# C test cases. (Can be run individually using make testcase.ctest.) +# C test cases. (Can be run individually using: make testcase.ctest) C_TEST_CASES += \ arrays \ char_constant \ @@ -460,7 +460,7 @@ C_TEST_CASES += \ unions -# Multi-module C++ test cases . (Can be run individually using make testcase.multicpptest.) +# Multi-module C++ test cases . (Can be run individually using make testcase.multicpptest) MULTI_CPP_TEST_CASES += \ clientdata_prop \ imports \ @@ -469,20 +469,13 @@ MULTI_CPP_TEST_CASES += \ template_typedef_import \ multi_import -# Non standard testcases, usually using custom commandline options -# Testcase names are prefixed with custom_ and can be run individually using make testcase.customtest -CUSTOM_TEST_CASES = \ - custom_wallkw \ +# Custom tests - tests with additional commandline options +custom_wallkw.cpptest: SWIGOPT += -Wallkw -# individual custom tests - any kind of customisation allowed here -# Note: $(basename $@) strips everything after and including the . in the target name -custom_wallkw.customtest: - $(MAKE) $(basename $@).cpptest SWIGOPTCUSTOM="-Wallkw" NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \ $(C_TEST_CASES:=.ctest) \ $(MULTI_CPP_TEST_CASES:=.multicpptest) \ - $(CUSTOM_TEST_CASES:=.customtest) \ $(EXTRA_TEST_CASES) BROKEN_TEST_CASES = $(CPP_TEST_BROKEN:=.cpptest) \ @@ -491,7 +484,6 @@ BROKEN_TEST_CASES = $(CPP_TEST_BROKEN:=.cpptest) \ ALL_CLEAN = $(CPP_TEST_CASES:=.clean) \ $(C_TEST_CASES:=.clean) \ $(MULTI_CPP_TEST_CASES:=.clean) \ - $(CUSTOM_TEST_CASES:=.clean) \ $(CPP_TEST_BROKEN:=.clean) \ $(C_TEST_BROKEN:=.clean) @@ -511,14 +503,14 @@ 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) $(SWIGOPTCUSTOM)" NOLINK=true \ + 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) $(SWIGOPTCUSTOM)" NOLINK=true \ + INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT) @@ -526,7 +518,7 @@ 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) $(SWIGOPTCUSTOM)" NOLINK=true \ + INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done @@ -538,7 +530,7 @@ swig_and_compile_external = \ $(LANGUAGE)$(VARIANT)_externalhdr; \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS) $*_external.cxx" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ - INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $(SWIGOPTCUSTOM)" NOLINK=true \ + INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index df5f1a7fd..ae6f2c113 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -15,14 +15,12 @@ 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 - -CUSTOM_TEST_CASES = \ - csharp_lib_arrays \ + exception_partial_info \ intermediary_classname include $(srcdir)/../common.mk @@ -33,6 +31,10 @@ 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) @@ -49,12 +51,6 @@ CSHARPFLAGSSPECIAL = +(cd $* && $(swig_and_compile_multi_cpp)) +$(run_testcase) -# Rules for custom tests -intermediary_classname.customtest: - $(MAKE) $(basename $@).cpptest SWIGOPTCUSTOM="-dllimport intermediary_classname" -csharp_lib_arrays.customtest: - $(MAKE) $(basename $@).cpptest CSHARPFLAGSSPECIAL="-unsafe" - # Makes a directory for the testcase if it does not exist setup = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in index 25d40674d..1fc63a436 100644 --- a/Examples/test-suite/guile/Makefile.in +++ b/Examples/test-suite/guile/Makefile.in @@ -17,6 +17,9 @@ 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) diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in index eb53f020e..ae7c7b96c 100644 --- a/Examples/test-suite/guilescm/Makefile.in +++ b/Examples/test-suite/guilescm/Makefile.in @@ -6,12 +6,15 @@ 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/ +# 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 = \ diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 03c10d498..8d4fbb546 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -40,6 +40,9 @@ include $(srcdir)/../common.mk SWIGOPT += -package $* INTERFACEDIR = ../../ +# Custom tests - tests with additional commandline options +# none! + # Rules for the different types of tests %.cpptest: $(setup) diff --git a/Examples/test-suite/lua/Makefile.in b/Examples/test-suite/lua/Makefile.in index b370ae163..d48a7c43b 100644 --- a/Examples/test-suite/lua/Makefile.in +++ b/Examples/test-suite/lua/Makefile.in @@ -24,6 +24,9 @@ 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) diff --git a/Examples/test-suite/mzscheme/Makefile.in b/Examples/test-suite/mzscheme/Makefile.in index 753b01ff6..7674dbee0 100644 --- a/Examples/test-suite/mzscheme/Makefile.in +++ b/Examples/test-suite/mzscheme/Makefile.in @@ -14,6 +14,9 @@ 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) diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 0e6235f94..4a7e363a7 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -44,6 +44,9 @@ 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 diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index b12cf500a..202adbbb8 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -34,6 +34,9 @@ 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) diff --git a/Examples/test-suite/perl5/Makefile.in b/Examples/test-suite/perl5/Makefile.in index 97079fa75..d9862abfe 100644 --- a/Examples/test-suite/perl5/Makefile.in +++ b/Examples/test-suite/perl5/Makefile.in @@ -27,6 +27,9 @@ 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) diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index d48f37e8a..021417fd2 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -16,6 +16,9 @@ include $(srcdir)/../common.mk # Overridden variables here TARGETPREFIX =# Should be php_ for Windows, empty otherwise +# Custom tests - tests with additional commandline options +# none! + # write out tests without a _runme.php missingcpptests: for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done diff --git a/Examples/test-suite/pike/Makefile.in b/Examples/test-suite/pike/Makefile.in index a753019ba..1a61086b6 100644 --- a/Examples/test-suite/pike/Makefile.in +++ b/Examples/test-suite/pike/Makefile.in @@ -14,6 +14,9 @@ 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) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index b8bd8944c..cf1f80389 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -89,6 +89,9 @@ include $(srcdir)/../common.mk LIBS = -L. VALGRIND_OPT += --suppressions=pythonswig.supp +# Custom tests - tests with additional commandline options +# none! + # Rules for the different types of tests %.cpptest: $(setup) diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 98d1f9571..242588640 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -16,6 +16,10 @@ 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: diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index d50b478be..e1d7e7889 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -38,12 +38,10 @@ include $(srcdir)/../common.mk # Overridden variables here SWIGOPT += -w801 -noautorename -features autodoc=4 - -# Rules for the different types of tests - -# make sure -autorename is true for the naming test +# 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) diff --git a/Examples/test-suite/tcl/Makefile.in b/Examples/test-suite/tcl/Makefile.in index 7c4b7ed61..bac2ae756 100644 --- a/Examples/test-suite/tcl/Makefile.in +++ b/Examples/test-suite/tcl/Makefile.in @@ -23,6 +23,9 @@ 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) diff --git a/Examples/test-suite/uffi/Makefile.in b/Examples/test-suite/uffi/Makefile.in index c09153d9e..4a45c1c6e 100644 --- a/Examples/test-suite/uffi/Makefile.in +++ b/Examples/test-suite/uffi/Makefile.in @@ -11,10 +11,14 @@ 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) From 144944dd8bf17f2f8386779faba6d5136dece9fb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 3 Jul 2009 22:28:07 +0000 Subject: [PATCH 031/352] rename custom_wallkw to wallkw - custom commandline tests needn't start with custom_ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11357 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 4 ++-- ...{custom_wallkw_runme.java => wallkw_runme.java} | 14 +++++++------- Examples/test-suite/{custom_wallkw.i => wallkw.i} | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) rename Examples/test-suite/java/{custom_wallkw_runme.java => wallkw_runme.java} (63%) rename Examples/test-suite/{custom_wallkw.i => wallkw.i} (96%) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index dcc5da2bd..74baddc81 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -142,7 +142,6 @@ CPP_TEST_CASES += \ cpp_nodefault \ cpp_static \ cpp_typedef \ - custom_wallkw \ default_args \ default_constructor \ defvalue_constructor \ @@ -395,6 +394,7 @@ CPP_TEST_CASES += \ virtual_destructor \ virtual_poly \ voidtest \ + wallkw \ wrapmacro # @@ -470,7 +470,7 @@ MULTI_CPP_TEST_CASES += \ multi_import # Custom tests - tests with additional commandline options -custom_wallkw.cpptest: SWIGOPT += -Wallkw +wallkw.cpptest: SWIGOPT += -Wallkw NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \ diff --git a/Examples/test-suite/java/custom_wallkw_runme.java b/Examples/test-suite/java/wallkw_runme.java similarity index 63% rename from Examples/test-suite/java/custom_wallkw_runme.java rename to Examples/test-suite/java/wallkw_runme.java index 08d9539bd..028c2a32f 100644 --- a/Examples/test-suite/java/custom_wallkw_runme.java +++ b/Examples/test-suite/java/wallkw_runme.java @@ -1,11 +1,11 @@ -import custom_wallkw.*; +import wallkw.*; -public class custom_wallkw_runme { +public class wallkw_runme { static { try { - System.loadLibrary("custom_wallkw"); + 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); @@ -13,13 +13,13 @@ public class custom_wallkw_runme { } public static void main(String argv[]) { - if (!custom_wallkw.c_clone().equals("clone")) + if (!wallkw.c_clone().equals("clone")) throw new RuntimeException("clone_c keyword fail"); - if (!custom_wallkw._delegate().equals("delegate")) + if (!wallkw._delegate().equals("delegate")) throw new RuntimeException("delegate keyword fail"); - if (!custom_wallkw._pass().equals("pass")) + if (!wallkw._pass().equals("pass")) throw new RuntimeException("pass keyword fail"); - if (!custom_wallkw.C_alias().equals("alias")) + if (!wallkw.C_alias().equals("alias")) throw new RuntimeException("alias keyword fail"); } } diff --git a/Examples/test-suite/custom_wallkw.i b/Examples/test-suite/wallkw.i similarity index 96% rename from Examples/test-suite/custom_wallkw.i rename to Examples/test-suite/wallkw.i index 1f4742a19..0ac383bcd 100644 --- a/Examples/test-suite/custom_wallkw.i +++ b/Examples/test-suite/wallkw.i @@ -1,4 +1,4 @@ -%module custom_wallkw +%module wallkw // test the -Wallkw option From 4851213163835e382409e6052d4116616b940427 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 3 Jul 2009 23:16:08 +0000 Subject: [PATCH 032/352] Improved way of overriding commandline options for the multicpptests git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11358 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/guile/Makefile.in | 22 +++++++--------------- Examples/test-suite/guilescm/Makefile.in | 10 +--------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in index 1fc63a436..afea6a850 100644 --- a/Examples/test-suite/guile/Makefile.in +++ b/Examples/test-suite/guile/Makefile.in @@ -9,8 +9,13 @@ 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 -C_TEST_CASES = long_long list_vector pointer_in_out multivalue include $(srcdir)/../common.mk @@ -18,7 +23,7 @@ include $(srcdir)/../common.mk # none! # Custom tests - tests with additional commandline options -# none! +%.multicpptest: SWIGOPT += $(GUILE_RUNTIME) # Rules for the different types of tests %.cpptest: @@ -31,19 +36,6 @@ include $(srcdir)/../common.mk +$(swig_and_compile_c) $(run_testcase) -# override the default in common.mk by adding SWIGOPT += -swig_and_compile_multi_cpp = \ - for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \ - SWIGOPT=" -runtime "; \ - export SWIGOPT; \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \ - SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ - INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $$SWIGOPT" NOLINK=true \ - TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ - $(LANGUAGE)$(VARIANT)_cpp; \ - SWIGOPT=" -noruntime "; \ - done - %.multicpptest: $(setup) +$(swig_and_compile_multi_cpp) diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in index ae7c7b96c..854b1ac7f 100644 --- a/Examples/test-suite/guilescm/Makefile.in +++ b/Examples/test-suite/guilescm/Makefile.in @@ -11,6 +11,7 @@ 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! @@ -29,15 +30,6 @@ setup = \ echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \ fi; -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) $$SWIGOPT" NOLINK=true \ - TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ - $(LANGUAGE)$(VARIANT)_cpp; \ - done - %.externaltest: $(local_setup) +$(swig_and_compile_external) From 31d43ea8c035a00be40391e1981b41fa9e274063 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 3 Jul 2009 23:32:14 +0000 Subject: [PATCH 033/352] Move custom commandline option overrides to new common section used in all other makefiles git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11359 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/chicken/Makefile.in | 49 +++++++++++++------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in index a3a2566bb..c5cbd827d 100644 --- a/Examples/test-suite/chicken/Makefile.in +++ b/Examples/test-suite/chicken/Makefile.in @@ -27,7 +27,16 @@ include $(srcdir)/../common.mk SWIGOPT += -nounit # Custom tests - tests with additional commandline options -# none! +# 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: @@ -59,6 +68,21 @@ SWIGOPT += -nounit +$(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 = \ @@ -66,29 +90,6 @@ run_testcase = \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \ fi; -# If there exists a PROXYSUFFIX runme file, we also generate the wrapper -# with the -proxy argument -%.cppproxy: SWIGOPT += -proxy -%.cppproxy: SCRIPTSUFFIX = $(PROXYSUFFIX) -%.cppproxy: - echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy" - +$(swig_and_compile_cpp) - $(run_testcase) - -%.cproxy: SWIGOPT += -proxy -%.cproxy: SCRIPTSUFFIX = $(PROXYSUFFIX) -%.cproxy: - echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy" - +$(swig_and_compile_c) - $(run_testcase) - -%.multiproxy: SWIGOPT += -proxy -noclosuses -%.multiproxy: SCRIPTSUFFIX = $(PROXYSUFFIX) -%.multiproxy: - echo "$(ACTION)ing testcase $* (with run test) under chicken with -proxy" - +$(swig_and_compile_multi_cpp) - $(run_testcase) - # Clean %.clean: From dc4474c95df06f4dfa4f0942bb76ef8cac266a23 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 5 Jul 2009 03:47:26 +0000 Subject: [PATCH 034/352] Use single quotes for string literals since we don't need or want substitutions to work. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11361 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index ee69c1864..e3b22f1d3 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -322,7 +322,7 @@ public: Printf(f_phpcode, "\n"); Printf(f_phpcode, "// Try to load our extension if it's not already loaded.\n"); - Printf(f_phpcode, "if (!extension_loaded(\"%s\")) {\n", module); + Printf(f_phpcode, "if (!extension_loaded('%s')) {\n", module); Printf(f_phpcode, " if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {\n"); Printf(f_phpcode, " if (!dl('php_%s.dll')) return;\n", module); Printf(f_phpcode, " } else {\n"); @@ -1383,7 +1383,7 @@ public: SwigType *t = Getattr(current_class, "classtype"); String *mangled_type = SwigType_manglestr(SwigType_ltype(t)); Printf(output, "\tfunction %s(%s) {\n", methodname, args); - Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) == \"_p%s\") {\n", arg0, arg0, mangled_type); + Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) == '_p%s') {\n", arg0, arg0, mangled_type); Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0); Printf(output, "\t\t\treturn;\n"); Printf(output, "\t\t}\n"); @@ -1433,7 +1433,7 @@ public: class_node = Getattr(zend_types, mangled); } if (i.item) { - Printf(output, "case \"%s\": ", mangled); + Printf(output, "case '%s': ", mangled); } else { Printf(output, "default: "); } @@ -1603,7 +1603,7 @@ public: } } else if (Strcmp(type, "include") == 0) { if (value) { - Printf(pragma_incl, "include \"%s\";\n", value); + Printf(pragma_incl, "include '%s';\n", value); } } else if (Strcmp(type, "phpinfo") == 0) { if (value) { From 9e919ef866ff6d9ba869bc46a8f68c068f2cdb2a Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 5 Jul 2009 04:06:39 +0000 Subject: [PATCH 035/352] Removed unused struct tag. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11362 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/phprun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index 5196b95b4..131c5ba3a 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -75,7 +75,7 @@ static int default_error_code = E_ERROR; /* used to wrap returned objects in so we know whether they are newobject and need freeing, or not */ -typedef struct _swig_object_wrapper { +typedef struct { void * ptr; int newobject; } swig_object_wrapper; From c83f80c0610c407d3c60dab6b7044efc5437f3b2 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 5 Jul 2009 05:00:16 +0000 Subject: [PATCH 036/352] Remove duplicate definitions of WARN_PHP_MULTIPLE_INHERITANCE and WARN_PHP_UNKNOWN_PRAGMA which were carefully providing backwards compatibility for WARN_PHP4_MULTIPLE_INHERITANCE and WARN_PHP4_UNKNOWN_PRAGMA until PHP4 was clobbered to PHP with search and replace hammer. This has now been broken in at least one release, so we'll just have to give up on trying to be helpful to existing users. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11366 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Include/swigwarn.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index e25e4408b..5be0305fa 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -248,13 +248,6 @@ /* please leave 850-869 free for Modula 3 */ -/* These are needed for backward compatibility, but you don't need to add - * PHP4 versions of new warnings since existing user interface files can't - * be using them. - */ -#define WARN_PHP_MULTIPLE_INHERITANCE 870 -#define WARN_PHP_UNKNOWN_PRAGMA 871 - #define WARN_PHP_MULTIPLE_INHERITANCE 870 #define WARN_PHP_UNKNOWN_PRAGMA 871 From 722b035705e6d10cc8a4787b432ad2009721b248 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 5 Jul 2009 05:04:48 +0000 Subject: [PATCH 037/352] Update URL for mingw download page on SF git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11367 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Windows.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index bc8c8fa51..5d16a8b9f 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -248,7 +248,7 @@ Execute the steps in the order shown and don't use spaces in path names. In fact
    1. Download the following packages from the MinGW download page - or MinGW SourceForge download page. + or MinGW SourceForge download page. Note that at the time of writing, the majority of these are in the Current release list and some are in the Snapshot or Previous release list.
        From 949ea9b580813b1b3333034be998343247f7c849 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sun, 5 Jul 2009 05:40:50 +0000 Subject: [PATCH 038/352] [PHP] Update the list of PHP keywords - "cfunction" is no longer a keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__", and "__NAMESPACE__". git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11368 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 ++ Examples/test-suite/throw_exception.i | 3 + Lib/php/phpkw.swg | 84 ++++++++++++++------------- 3 files changed, 53 insertions(+), 39 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f6906e0a3..06c0c8851 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.40 (in progress) ============================ +2009-07-05: olly + [PHP] Update the list of PHP keywords - "cfunction" is no longer a + keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__", + and "__NAMESPACE__". + 2009-07-03: olly [Tcl] To complement USE_TCL_STUBS, add support for USE_TK_STUBS and SWIG_TCL_STUBS_VERSION. Document all three in the Tcl chapter diff --git a/Examples/test-suite/throw_exception.i b/Examples/test-suite/throw_exception.i index 9a0ddabde..c1ad945fb 100644 --- a/Examples/test-suite/throw_exception.i +++ b/Examples/test-suite/throw_exception.i @@ -8,6 +8,9 @@ %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 diff --git a/Lib/php/phpkw.swg b/Lib/php/phpkw.swg index 3d1a62511..af1a8f825 100644 --- a/Lib/php/phpkw.swg +++ b/Lib/php/phpkw.swg @@ -8,21 +8,22 @@ * when used as class methods. * ----------------------------------------------------------------------------- */ -#define PHPKW(x) %keywordwarn("'" `x` "' is a php keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s", rename="c_%s",fullname=1) `x` +#define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s", rename="c_%s",fullname=1) `x` %define PHPCN(x) -%keywordwarn("'" `x` "' is a php reserved class name, class renamed as 'c_" `x` "'",%$isclass,rename="c_%s") `x`; -%keywordwarn("'" `x` "' is a php reserved class name, constructor renamed as 'c_" `x` "'",%$isconstructor,rename="c_%s") `x`; +%keywordwarn("'" `x` "' is a PHP reserved class name, class renamed as 'c_" `x` "'",%$isclass,rename="c_%s") `x`; +%keywordwarn("'" `x` "' is a PHP reserved class name, constructor renamed as 'c_" `x` "'",%$isconstructor,rename="c_%s") `x`; %enddef -#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in php",sourcefmt="%(lower)s",fullname=1) `x` -#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in php") "::" `x` +#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP",sourcefmt="%(lower)s",fullname=1) `x` +#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP") "::" `x` /* From http://aspn.activestate.com/ASPN/docs/PHP/reserved.html + http://php.net/manual/en/reserved.keywords.php and reviewed by Olly Betts. @@ -30,76 +31,81 @@ */ /* We classify these as kw since PHP will not run if used globally. */ +/* "You cannot use any of the following words as constants, class names, + * function or method names. Using them as variable names is generally OK, but + * could lead to confusion." + */ /* case insensitive */ +PHPKW(__halt_compiler); +PHPKW(abstract); PHPKW(and); PHPKW(array); PHPKW(as); PHPKW(break); PHPKW(case); -PHPKW(cfunction); /* No longer reserved in PHP5 */ +PHPKW(catch); PHPKW(class); +PHPKW(clone); PHPKW(const); PHPKW(continue); PHPKW(declare); PHPKW(default); -PHPKW(die); +PHPKW(die); // "Language construct" PHPKW(do); -PHPKW(echo); +PHPKW(echo); // "Language construct" PHPKW(else); PHPKW(elseif); -PHPKW(empty); +PHPKW(empty); // "Language construct" PHPKW(enddeclare); PHPKW(endfor); PHPKW(endforeach); PHPKW(endif); PHPKW(endswitch); PHPKW(endwhile); -PHPKW(eval); -PHPKW(exit); +PHPKW(eval); // "Language construct" +PHPKW(exit); // "Language construct" PHPKW(extends); +PHPKW(final); PHPKW(for); PHPKW(foreach); PHPKW(function); PHPKW(global); +PHPKW(goto); // As of PHP5.3 PHPKW(if); -PHPKW(include); -PHPKW(include_once); -PHPKW(isset); -PHPKW(list); +PHPKW(implements); +PHPKW(include); // "Language construct" +PHPKW(include_once); // "Language construct" +PHPKW(instanceof); +PHPKW(interface); +PHPKW(isset); // "Language construct" +PHPKW(list); // "Language construct" +PHPKW(namespace); // As of PHP5.3 PHPKW(new); -// PHPKW(old_function); /* No longer reserved in PHP5 */ PHPKW(or); -PHPKW(print); -PHPKW(require); -PHPKW(require_once); -PHPKW(return); +PHPKW(print); // "Language construct" +PHPKW(private); +PHPKW(protected); +PHPKW(public); +PHPKW(require); // "Language construct" +PHPKW(require_once); // "Language construct" +PHPKW(return); // "Language construct" PHPKW(static); PHPKW(switch); -PHPKW(unset); +PHPKW(throw); +PHPKW(try); +PHPKW(unset); // "Language construct" PHPKW(use); PHPKW(var); PHPKW(while); PHPKW(xor); -PHPKW(__FILE__); -PHPKW(__LINE__); -PHPKW(__FUNCTION__); +// Compile-time constants PHPKW(__CLASS__); - -/* Added in PHP5 */ -PHPKW(__halt_compiler); -PHPKW(abstract); -PHPKW(catch); -PHPKW(clone); -PHPKW(final); -PHPKW(implements); -PHPKW(instanceof); -PHPKW(interface); -PHPKW(private); -PHPKW(protected); -PHPKW(public); -PHPKW(throw); -PHPKW(try); +PHPKW(__DIR__); // As of PHP5.3 +PHPKW(__FILE__); +PHPKW(__FUNCTION__); PHPKW(__METHOD__); +PHPKW(__NAMESPACE__); // As of PHP5.3 +PHPKW(__LINE__); /* We classify these as built-in names since they conflict, but PHP still runs */ From 531e3413099091779c6410f41e1baa73968e70c0 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 6 Jul 2009 06:48:37 +0000 Subject: [PATCH 039/352] Fix rename_scope testcase to pass git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11370 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/rename_scope_runme.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/php/rename_scope_runme.php b/Examples/test-suite/php/rename_scope_runme.php index 33925a6db..6da5c4a5c 100644 --- a/Examples/test-suite/php/rename_scope_runme.php +++ b/Examples/test-suite/php/rename_scope_runme.php @@ -6,12 +6,12 @@ require "rename_scope.php"; check::classes(array("rename_scope","Interface_UP","Interface_BP","Natural_UP","Natural_BP","Bucket")); -check::classmethods("Interface_UP",array("interface_up")); -check::classmethods("Interface_BP",array("interface_bp")); -check::classmethods("Natural_UP",array("interface_up","natural_up","rtest")); -check::classmethods("Natural_BP",array("interface_bp","natural_bp","rtest")); -check::classparent("Natural_UP","interface_up"); -check::classparent("Natural_BP","interface_bp"); +check::classmethods("Interface_UP",array("__construct")); +check::classmethods("Interface_BP",array("__construct")); +check::classmethods("Natural_UP",array("__construct","rtest")); +check::classmethods("Natural_BP",array("__construct","rtest")); +check::classparent("Natural_UP","Interface_UP"); +check::classparent("Natural_BP","Interface_BP"); check::done(); ?> From 224c83ef096de1a6817c3582394e60315d43c4e5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 8 Jul 2009 12:17:45 +0000 Subject: [PATCH 040/352] Typemap API changes to facilitate more uniform typemap handling across language modules - in particular some typemaps usage did not respect the warning attribute and other warning handling and $typemap special variable (which will be refined in future commit) as well as local typemap variable handling: - remove Swig_typemap_search, Swig_typemap_search_multi and Swig_typemap_attach_kwargs from access outside of typemaps.c (made static) - all static methods in typemap.c renamed dropping Swig_ prefix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11380 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/allegrocl.cxx | 143 ++++++++++++++++------------------- Source/Modules/cffi.cxx | 19 +++-- Source/Modules/clisp.cxx | 37 +++++---- Source/Modules/csharp.cxx | 97 +++++++++++++----------- Source/Modules/java.cxx | 102 +++++++++++++------------ Source/Modules/modula3.cxx | 72 ++++++++++-------- Source/Modules/uffi.cxx | 42 +++++----- Source/Swig/swig.h | 3 - Source/Swig/typemap.c | 69 ++++++++--------- 9 files changed, 304 insertions(+), 280 deletions(-) diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 1eb12630c..91bfdf2ea 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -626,7 +626,7 @@ void note_implicit_template_instantiation(SwigType *t) { add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace); } -String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) { +String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) { /* lookup defined foreign type. if it exists, it will return a form suitable for placing into lisp code to generate the def-foreign-type name */ @@ -641,18 +641,20 @@ String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "found_type '%s'\n", found_type); #endif - return (Strcmp(found_type, "forward-reference") ? Copy(found_type) : - get_ffi_type(fwdref_ffi_type, "")); + return (Strcmp(found_type, "forward-reference") ? Copy(found_type) : get_ffi_type(n, fwdref_ffi_type, "")); } else { - Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0); - - if (typemap) { - String *typespec = Getattr(typemap, "code"); + Node *node = NewHash(); + Setattr(node, "type", ty); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *tm = Swig_typemap_lookup("ffitype", node, name, 0); + Delete(node); + if (tm) { #ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "g-f-t: found ffitype typemap '%s'\n%s\n", typespec, typemap); + Printf(stderr, "g-f-t: found ffitype typemap '%s'\n", tm); #endif - return NewString(typespec); + return NewString(tm); } if (SwigType_istemplate(ty)) { @@ -673,7 +675,7 @@ String *lookup_defined_foreign_ltype(String *l) { /* walk type and return string containing lisp version. recursive. */ -String *internal_compose_foreign_type(SwigType *ty) { +String *internal_compose_foreign_type(Node *n, SwigType *ty) { SwigType *tok; String *ffiType = NewString(""); @@ -691,18 +693,18 @@ String *internal_compose_foreign_type(SwigType *ty) { Printf(ffiType, "("); // start parm list for (Iterator i = First(pl); i.item; i = Next(i)) { SwigType *f_arg = SwigType_strip_qualifiers(i.item); - Printf(ffiType, "%s ", internal_compose_foreign_type(f_arg)); + Printf(ffiType, "%s ", internal_compose_foreign_type(n, f_arg)); Delete(f_arg); } Printf(ffiType, ")"); // end parm list. // do function return type. - Printf(ffiType, " %s)", internal_compose_foreign_type(ty)); + Printf(ffiType, " %s)", internal_compose_foreign_type(n, ty)); break; } else if (SwigType_ispointer(tok) || SwigType_isreference(tok)) { - Printf(ffiType, "(* %s)", internal_compose_foreign_type(ty)); + Printf(ffiType, "(* %s)", internal_compose_foreign_type(n, ty)); } else if (SwigType_isarray(tok)) { - Printf(ffiType, "(:array %s", internal_compose_foreign_type(ty)); + Printf(ffiType, "(:array %s", internal_compose_foreign_type(n, ty)); String *atype = NewString("int"); String *dim = convert_literal(SwigType_array_getdim(tok, 0), atype); Delete(atype); @@ -713,18 +715,18 @@ String *internal_compose_foreign_type(SwigType *ty) { } } else if (SwigType_ismemberpointer(tok)) { // temp - Printf(ffiType, "(* %s)", internal_compose_foreign_type(ty)); + Printf(ffiType, "(* %s)", internal_compose_foreign_type(n, ty)); } else { - String *res = get_ffi_type(tok, ""); + String *res = get_ffi_type(n, tok, ""); if (res) { Printf(ffiType, "%s", res); } else { SwigType *resolved_type = SwigType_typedef_resolve(tok); if (resolved_type) { - res = get_ffi_type(resolved_type, ""); + res = get_ffi_type(n, resolved_type, ""); if (res) { } else { - res = internal_compose_foreign_type(resolved_type); + res = internal_compose_foreign_type(n, resolved_type); } if (res) Printf(ffiType, "%s", res); @@ -762,7 +764,7 @@ String *internal_compose_foreign_type(SwigType *ty) { add_forward_referenced_type(nn, 0); // tok_name is dangling here, unused. ouch. why? - Printf(ffiType, "%s", get_ffi_type(tok, ""), tok_name); + Printf(ffiType, "%s", get_ffi_type(n, tok, ""), tok_name); } } } @@ -770,9 +772,7 @@ String *internal_compose_foreign_type(SwigType *ty) { return ffiType; } -String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) { - -/* Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); */ +String *compose_foreign_type(Node *n, SwigType *ty, String * /*id*/ = 0) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty); @@ -802,7 +802,7 @@ String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) { */ SwigType *temp = SwigType_strip_qualifiers(ty); - String *res = internal_compose_foreign_type(temp); + String *res = internal_compose_foreign_type(n, temp); Delete(temp); #ifdef ALLEGROCL_TYPE_DEBUG @@ -1239,7 +1239,7 @@ void emit_full_class(Node *n) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "slot name = '%s' ns = '%s' class-of '%s' and type = '%s'\n", cname, ns, name, childType); #endif - Printf(slotdefs, "(#.(swig-insert-id \"%s\" %s :type :slot :class \"%s\") %s)", cname, ns, name, compose_foreign_type(childType)); + Printf(slotdefs, "(#.(swig-insert-id \"%s\" %s :type :slot :class \"%s\") %s)", cname, ns, name, compose_foreign_type(n, childType)); Delete(ns); if (access && Strcmp(access, "public")) Printf(slotdefs, " ;; %s member", access); @@ -1322,7 +1322,7 @@ void emit_typedef(Node *n) { String *name; String *sym_name = Getattr(n, "sym:name"); String *type = NewStringf("%s%s", Getattr(n, "decl"), Getattr(n, "type")); - String *lisp_type = compose_foreign_type(type); + String *lisp_type = compose_foreign_type(n, type); Delete(type); Node *in_class = Getattr(n, "allegrocl:typedef:in-class"); @@ -1371,9 +1371,13 @@ void emit_enum_type_no_wrap(Node *n) { name = unnamed ? Getattr(n, "allegrocl:name") : Getattr(n, "sym:name"); SwigType *tmp = NewStringf("enum %s", unnamed ? unnamed : name); - Hash *typemap = Swig_typemap_search("ffitype", tmp, 0, 0); - String *enumtype = Getattr(typemap, "code"); - // enumtype = compose_foreign_type(tmp); + Node *node = NewHash(); + Setattr(node, "type", tmp); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *enumtype = Swig_typemap_lookup("ffitype", node, "", 0); + Delete(node); + Delete(tmp); if (name) { @@ -1427,12 +1431,14 @@ void emit_enum_type(Node *n) { name = unnamed ? Getattr(n, "allegrocl:name") : Getattr(n, "sym:name"); SwigType *tmp = NewStringf("enum %s", unnamed ? unnamed : name); - // SwigType *tmp = NewStringf("enum ACL_SWIG_ENUM_NAME"); - Hash *typemap = Swig_typemap_search("ffitype", tmp, 0, 0); - String *enumtype = Getattr(typemap, "code"); + Node *node = NewHash(); + Setattr(node, "type", tmp); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *enumtype = Swig_typemap_lookup("ffitype", node, "", 0); + Delete(node); - // enumtype = compose_foreign_type(tmp); Delete(tmp); if (name) { @@ -1979,14 +1985,16 @@ int any_varargs(ParmList *pl) { return 0; } -String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) { - Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0); - if (typemap) { - String *typespec = Getattr(typemap, "code"); - return NewString(typespec); - } else { - return NewString(""); - } +String *get_lisp_type(Node *n, SwigType *ty, const_String_or_char_ptr name) { + Node *node = NewHash(); + Setattr(node, "type", ty); + Setattr(node, "name", name); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *tm = Swig_typemap_lookup("lisptype", node, "", 0); + Delete(node); + + return tm ? NewString(tm) : NewString(""); } Node *parent_node_skipping_extends(Node *n) { @@ -2274,18 +2282,21 @@ int ALLEGROCL::emit_buffered_defuns(Node *n) { return SWIG_OK; } -String *dispatching_type(Parm *p) { +String *dispatching_type(Node *n, Parm *p) { String *result = 0; String *parsed = Getattr(p, "type"); //Swig_cparse_type(Getattr(p,"tmap:ctype")); String *cl_t = SwigType_typedef_resolve_all(parsed); - Hash *typemap = Swig_typemap_search("lispclass", parsed, Getattr(p, "name"), 0); - // Printf(stderr,"inspecting type '%s' for class\n", parsed); - // Printf(stderr," cfcocr = '%s' res_all = '%s'\n", - // class_from_class_or_class_ref(parsed), cl_t); - if (typemap) { - result = Copy(Getattr(typemap, "code")); + Node *node = NewHash(); + Setattr(node, "type", parsed); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *tm = Swig_typemap_lookup("lispclass", node, Getattr(p, "name"), 0); + Delete(node); + + if (tm) { + result = Copy(tm); } else { String *lookup_type = class_from_class_or_class_ref(parsed); if (lookup_type) @@ -2305,24 +2316,6 @@ String *dispatching_type(Parm *p) { return result; } -String *defmethod_lambda_list(Node *overload) { - String *result = NewString(""); - - ParmList *parms = Getattr(overload, "wrap:parms"); - Parm *p; - int a; - - for (a = 0, p = parms; p; p = nextSibling(p), ++a) { - if (a != 0) - Printf(result, " "); - Printf(result, "(arg%d ", a); - Printf(result, "%s", dispatching_type(p)); - Printf(result, ")"); - } - - return result; -} - int ALLEGROCL::emit_dispatch_defun(Node *n) { #ifdef ALLEGROCL_WRAP_DEBUG Printf(stderr, "emit_dispatch_defun: ENTER... "); @@ -2429,9 +2422,9 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { String *argname = NewStringf("PARM%d_%s", largnum, Getattr(p, "name")); // Printf(stderr,"%s\n", Getattr(p,"tmap:lin")); - String *ffitype = compose_foreign_type(argtype, Getattr(p,"name")); + String *ffitype = compose_foreign_type(n, argtype, Getattr(p,"name")); String *deref_ffitype = dereference_ffitype(ffitype); - String *lisptype = get_lisp_type(parmtype, Getattr(p, "name")); + String *lisptype = get_lisp_type(n, parmtype, Getattr(p, "name")); #ifdef ALLEGROCL_DEBUG Printf(stderr, "lisptype of '%s' '%s' = '%s'\n", parmtype, @@ -2454,7 +2447,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { Replaceall(wrap->code, "$body", parm_code); } - String *dispatchtype = Getattr(n, "sym:overloaded") ? dispatching_type(p) : NewString(""); + String *dispatchtype = Getattr(n, "sym:overloaded") ? dispatching_type(n, p) : NewString(""); // if this parameter has been removed from the C/++ wrapper // it shouldn't be in the lisp wrapper either. @@ -2485,13 +2478,13 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { SwigType *parsed = Swig_cparse_type(Getattr(n, "tmap:ctype")); // SwigType *cl_t = SwigType_typedef_resolve_all(parsed); SwigType *cl_t = class_from_class_or_class_ref(parsed); - String *out_ffitype = compose_foreign_type(parsed); + String *out_ffitype = compose_foreign_type(n, parsed); String *deref_out_ffitype; String *out_temp = Copy(parsed); if (SwigType_ispointer(out_temp)) { SwigType_pop(out_temp); - deref_out_ffitype = compose_foreign_type(out_temp); + deref_out_ffitype = compose_foreign_type(n, out_temp); } else { deref_out_ffitype = Copy(out_ffitype); } @@ -2547,7 +2540,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { ///////////////////////////////////////////////////// // Lisp foreign call return type and optimizations // ///////////////////////////////////////////////////// - Printf(fcl, " (:returning (%s %s)", compose_foreign_type(result_type), get_lisp_type(Getattr(n, "type"), "result")); + Printf(fcl, " (:returning (%s %s)", compose_foreign_type(n, result_type), get_lisp_type(n, Getattr(n, "type"), "result")); for (Iterator option = First(n); option.item; option = Next(option)) { if (Strncmp("feature:ffargs:", option.key, 15)) @@ -2926,10 +2919,6 @@ int ALLEGROCL::variableWrapper(Node *n) { Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name); Printf(f_cl, "(swig-defvar \"%s\" :type %s)\n", mangled_name, ((SwigType_isconst(type)) ? ":constant" : ":variable")); - /* - Printf(f_runtime, "// swigtype: %s\n", SwigType_typedef_resolve_all(Getattr(n,"type"))); - Printf(f_runtime, "// vwrap: %s\n", compose_foreign_type(SwigType_strip_qualifiers(Copy(rtype)))); - */ Printf(stderr,"***\n"); Delete(mangled_name); @@ -2971,7 +2960,7 @@ int ALLEGROCL::typedefHandler(Node *n) { SwigType *typedef_type = Getattr(n,"type"); // has the side-effect of noting any implicit // template instantiations in type. - String *ff_type = compose_foreign_type(typedef_type); + String *ff_type = compose_foreign_type(n, typedef_type); String *sym_name = Getattr(n, "sym:name"); @@ -3132,7 +3121,7 @@ int ALLEGROCL::cppClassHandler(Node *n) { Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType); #endif if (!SwigType_isfunction(childType)) - Delete(compose_foreign_type(childType)); + Delete(compose_foreign_type(n, childType)); Delete(childType); } diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 0aa933c56..062b9f0ff 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -819,21 +819,24 @@ void CFFI::emit_struct_union(Node *n, bool un = false) { // Getattr(c, "type")); // SWIG_exit(EXIT_FAILURE); } else { - SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), - Getattr(c, "type")); + SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type")); - Hash *typemap = Swig_typemap_search("cin", childType, "", 0); - String *typespec = NewString(""); - if (typemap) { - typespec = NewString(Getattr(typemap, "code")); - } + Node *node = NewHash(); + Setattr(node, "type", childType); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *tm = Swig_typemap_lookup("cin", node, "", 0); + + String *typespec = tm ? NewString(tm) : NewString(""); String *slot_name = lispify_name(c, Getattr(c, "sym:name"), "'slotname"); if (Strcmp(slot_name, "t") == 0 || Strcmp(slot_name, "T") == 0) - slot_name = NewStringf("t_var"); + slot_name = NewStringf("t_var"); Printf(f_cl, "\n\t(%s %s)", slot_name, typespec); + Delete(node); + Delete(childType); Delete(typespec); } } diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx index fa73b3a0b..46c5ef84a 100644 --- a/Source/Modules/clisp.cxx +++ b/Source/Modules/clisp.cxx @@ -25,7 +25,7 @@ public: virtual int typedefHandler(Node *n); List *entries; private: - String *get_ffi_type(SwigType *ty); + String *get_ffi_type(Node *n, SwigType *ty); String *convert_literal(String *num_param, String *type); String *strip_parens(String *string); int extern_all_flag; @@ -167,7 +167,7 @@ int CLISP::functionWrapper(Node *n) { String *argname = Getattr(p, "name"); // SwigType *argtype; - String *ffitype = get_ffi_type(Getattr(p, "type")); + String *ffitype = get_ffi_type(n, Getattr(p, "type")); int tempargname = 0; @@ -190,7 +190,7 @@ int CLISP::functionWrapper(Node *n) { if (ParmList_len(pl) != 0) { Printf(f_cl, ")\n"); /* finish arg list */ } - String *ffitype = get_ffi_type(Getattr(n, "type")); + String *ffitype = get_ffi_type(n, Getattr(n, "type")); if (Strcmp(ffitype, "NIL")) { //when return type is not nil Printf(f_cl, "\t(:return-type %s)\n", ffitype); } @@ -222,7 +222,7 @@ int CLISP::variableWrapper(Node *n) { return SWIG_OK; String *var_name = Getattr(n, "sym:name"); - String *lisp_type = get_ffi_type(Getattr(n, "type")); + String *lisp_type = get_ffi_type(n, Getattr(n, "type")); Printf(f_cl, "\n(ffi:def-c-var %s\n (:name \"%s\")\n (:type %s)\n", var_name, var_name, lisp_type); Printf(f_cl, "\t(:library +library-name+))\n"); Append(entries, var_name); @@ -234,7 +234,7 @@ int CLISP::variableWrapper(Node *n) { int CLISP::typedefHandler(Node *n) { if (generate_typedef_flag) { is_function = 0; - Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(Getattr(n, "type"))); + Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(n, Getattr(n, "type"))); } return Language::typedefHandler(n); @@ -290,7 +290,7 @@ int CLISP::classDeclaration(Node *n) { String *temp = Copy(Getattr(c, "decl")); Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type - String *lisp_type = get_ffi_type(temp); + String *lisp_type = get_ffi_type(n, temp); Delete(temp); String *slot_name = Getattr(c, "sym:name"); @@ -371,15 +371,20 @@ String *CLISP::convert_literal(String *num_param, String *type) { return res; } -String *CLISP::get_ffi_type(SwigType *ty) { - Hash *typemap = Swig_typemap_search("in", ty, "", 0); - if (typemap) { - String *typespec = Getattr(typemap, "code"); - return NewString(typespec); +String *CLISP::get_ffi_type(Node *n, SwigType *ty) { + Node *node = NewHash(); + Setattr(node, "type", ty); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *tm = Swig_typemap_lookup("in", node, "", 0); + Delete(node); + + if (tm) { + return NewString(tm); } else if (SwigType_ispointer(ty)) { SwigType *cp = Copy(ty); SwigType_del_pointer(cp); - String *inner_type = get_ffi_type(cp); + String *inner_type = get_ffi_type(n, cp); if (SwigType_isfunction(cp)) { return inner_type; @@ -409,12 +414,12 @@ String *CLISP::get_ffi_type(SwigType *ty) { Delete(array_dim); SwigType_del_array(cp); SwigType_add_pointer(cp); - String *str = get_ffi_type(cp); + String *str = get_ffi_type(n, cp); Delete(cp); return str; } else { SwigType_pop_arrays(cp); - String *inner_type = get_ffi_type(cp); + String *inner_type = get_ffi_type(n, cp); Delete(cp); int ndim = SwigType_array_ndim(ty); @@ -455,7 +460,7 @@ String *CLISP::get_ffi_type(SwigType *ty) { for (Parm *p = pl; p; p = nextSibling(p), argnum++) { String *argname = Getattr(p, "name"); SwigType *argtype = Getattr(p, "type"); - String *ffitype = get_ffi_type(argtype); + String *ffitype = get_ffi_type(n, argtype); int tempargname = 0; @@ -475,7 +480,7 @@ String *CLISP::get_ffi_type(SwigType *ty) { if (ParmList_len(pl) != 0) { Printf(args, ")\n"); /* finish arg list */ } - String *ffitype = get_ffi_type(cp); + String *ffitype = get_ffi_type(n, cp); String *str = NewStringf("(ffi:c-function %s \t\t\t\t(:return-type %s))", args, ffitype); Delete(fn); Delete(args); diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 82abc4803..9154f959a 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1115,16 +1115,16 @@ public: // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum // Pure C# baseclass and interfaces - const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE); - const String *pure_interfaces = typemapLookup("csinterfaces", typemap_lookup_type, WARN_NONE); + const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE); + const String *pure_interfaces = typemapLookup(n, "csinterfaces", typemap_lookup_type, WARN_NONE); // Class attributes - const String *csattributes = typemapLookup("csattributes", typemap_lookup_type, WARN_NONE); + const String *csattributes = typemapLookup(n, "csattributes", typemap_lookup_type, WARN_NONE); if (csattributes && *Char(csattributes)) Printf(enum_code, "%s\n", csattributes); // Emit the enum - Printv(enum_code, typemapLookup("csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really) + Printv(enum_code, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really) " ", symname, (*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces ", " : "", pure_interfaces, " {\n", NIL); } else { @@ -1140,8 +1140,8 @@ public: // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum // Finish the enum declaration // Typemaps are used to generate the enum definition in a similar manner to proxy classes. - Printv(enum_code, (enum_feature == ProperEnum) ? "\n" : typemapLookup("csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class - typemapLookup("cscode", typemap_lookup_type, WARN_NONE), // extra C# code + Printv(enum_code, (enum_feature == ProperEnum) ? "\n" : typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class + typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code "}", NIL); Replaceall(enum_code, "$csclassname", symname); @@ -1177,7 +1177,7 @@ public: addOpenNamespace(namespce, f_enum); - Printv(f_enum, typemapLookup("csimports", typemap_lookup_type, WARN_NONE), // Import statements + Printv(f_enum, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", enum_code, "\n", NIL); addCloseNamespace(namespce, f_enum); @@ -1243,7 +1243,7 @@ public: // Wrap C/C++ enums with constant integers or use the typesafe enum pattern const String *parent_name = Getattr(parentNode(n), "name"); String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int"); - const String *tm = typemapLookup("cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF); + const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF); String *return_type = Copy(tm); Delete(typemap_lookup_type); typemap_lookup_type = NULL; @@ -1490,12 +1490,12 @@ public: String *c_baseclass = NULL; String *baseclass = NULL; String *c_baseclassname = NULL; - String *typemap_lookup_type = Getattr(n, "classtypeobj"); + SwigType *typemap_lookup_type = Getattr(n, "classtypeobj"); bool feature_director = Swig_directorclass(n) ? true : false; // Inheritance from pure C# classes Node *attributes = NewHash(); - const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE, attributes); + const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE, attributes); bool purebase_replace = GetFlag(attributes, "tmap:csbase:replace") ? true : false; bool purebase_notderived = GetFlag(attributes, "tmap:csbase:notderived") ? true : false; Delete(attributes); @@ -1549,21 +1549,21 @@ public: } // Pure C# interfaces - const String *pure_interfaces = typemapLookup(derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE); + const String *pure_interfaces = typemapLookup(n, derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE); // Start writing the proxy class - Printv(proxy_class_def, typemapLookup("csimports", typemap_lookup_type, WARN_NONE), // Import statements + Printv(proxy_class_def, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", NIL); // Class attributes - const String *csattributes = typemapLookup("csattributes", typemap_lookup_type, WARN_NONE); + const String *csattributes = typemapLookup(n, "csattributes", typemap_lookup_type, WARN_NONE); if (csattributes && *Char(csattributes)) Printf(proxy_class_def, "%s\n", csattributes); - Printv(proxy_class_def, typemapLookup("csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers + Printv(proxy_class_def, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " $csclassname", // Class name and base class (*Char(wanted_base) || *Char(pure_interfaces)) ? " : " : "", wanted_base, (*Char(wanted_base) && *Char(pure_interfaces)) ? // Interfaces - ", " : "", pure_interfaces, " {", derived ? typemapLookup("csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class - typemapLookup("csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class + ", " : "", pure_interfaces, " {", derived ? typemapLookup(n, "csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class + typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class NIL); // C++ destructor is wrapped by the Dispose method @@ -1574,11 +1574,11 @@ public: String *destruct_methodname = NULL; String *destruct_methodmodifiers = NULL; if (derived) { - tm = typemapLookup("csdestruct_derived", typemap_lookup_type, WARN_NONE, attributes); + tm = typemapLookup(n, "csdestruct_derived", typemap_lookup_type, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:csdestruct_derived:methodname"); destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct_derived:methodmodifiers"); } else { - tm = typemapLookup("csdestruct", typemap_lookup_type, WARN_NONE, attributes); + tm = typemapLookup(n, "csdestruct", typemap_lookup_type, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:csdestruct:methodname"); destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct:methodmodifiers"); } @@ -1595,7 +1595,7 @@ public: if (tm) { // Finalize method if (*Char(destructor_call)) { - Printv(proxy_class_def, typemapLookup("csfinalize", typemap_lookup_type, WARN_NONE), NIL); + Printv(proxy_class_def, typemapLookup(n, "csfinalize", typemap_lookup_type, WARN_NONE), NIL); } // Dispose method Printv(destruct, tm, NIL); @@ -1690,7 +1690,7 @@ public: Delete(destruct); // Emit extra user code - Printv(proxy_class_def, typemapLookup("cscode", typemap_lookup_type, WARN_NONE), // extra C# code + Printv(proxy_class_def, typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code "\n", NIL); // Substitute various strings into the above template @@ -2355,7 +2355,7 @@ public: /* Insert the csconstruct typemap, doing the replacement for $directorconnect, as needed */ Hash *attributes = NewHash(); - String *construct_tm = Copy(typemapLookup("csconstruct", Getattr(n, "name"), + String *construct_tm = Copy(typemapLookup(n, "csconstruct", Getattr(n, "name"), WARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF, attributes)); if (construct_tm) { if (!feature_director) { @@ -2972,6 +2972,10 @@ public: * ----------------------------------------------------------------------------- */ void emitTypeWrapperClass(String *classname, SwigType *type) { + Node *n = NewHash(); + Setfile(n, input_file); + Setline(n, line_number); + String *swigtype = NewString(""); String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), classname); File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); @@ -2989,23 +2993,23 @@ public: addOpenNamespace(namespce, f_swigtype); // Pure C# baseclass and interfaces - const String *pure_baseclass = typemapLookup("csbase", type, WARN_NONE); - const String *pure_interfaces = typemapLookup("csinterfaces", type, WARN_NONE); + const String *pure_baseclass = typemapLookup(n, "csbase", type, WARN_NONE); + const String *pure_interfaces = typemapLookup(n, "csinterfaces", type, WARN_NONE); // Emit the class - Printv(swigtype, typemapLookup("csimports", type, WARN_NONE), // Import statements + Printv(swigtype, typemapLookup(n, "csimports", type, WARN_NONE), // Import statements "\n", NIL); // Class attributes - const String *csattributes = typemapLookup("csattributes", type, WARN_NONE); + const String *csattributes = typemapLookup(n, "csattributes", type, WARN_NONE); if (csattributes && *Char(csattributes)) Printf(swigtype, "%s\n", csattributes); - Printv(swigtype, typemapLookup("csclassmodifiers", type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers + Printv(swigtype, typemapLookup(n, "csclassmodifiers", type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " $csclassname", // Class name and base class (*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces - ", " : "", pure_interfaces, " {", typemapLookup("csbody", type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class - typemapLookup("cscode", type, WARN_NONE), // extra C# code + ", " : "", pure_interfaces, " {", typemapLookup(n, "csbody", type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class + typemapLookup(n, "cscode", type, WARN_NONE), // extra C# code "}\n", NIL); Replaceall(swigtype, "$csclassname", classname); @@ -3019,29 +3023,34 @@ public: Close(f_swigtype); Delete(swigtype); + Delete(n); } /* ----------------------------------------------------------------------------- * typemapLookup() + * n - for input only and must contain info for Getfile(n) and Getline(n) to work + * op - typemap method name + * type - typemap type to lookup + * warning - warning number to issue if no typemaps found + * typemap_attributes - the typemap attributes are attached to this node and will + * also be used for temporary storage if non null + * return is never NULL, unlike Swig_typemap_lookup() * ----------------------------------------------------------------------------- */ - const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) { - String *tm = NULL; - const String *code = NULL; - - if ((tm = Swig_typemap_search(op, type, NULL, NULL))) { - code = Getattr(tm, "code"); - if (typemap_attributes) - Swig_typemap_attach_kwargs(tm, op, typemap_attributes); - } - - if (!code) { - code = empty_string; + const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) { + Node *node = !typemap_attributes ? NewHash() : typemap_attributes; + Setattr(node, "type", type); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *tm = Swig_typemap_lookup(op, node, "", 0); + if (!tm) { + tm = empty_string; if (warning != WARN_NONE) - Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type); + Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0)); } - - return code ? code : empty_string; + if (!typemap_attributes) + Delete(node); + return tm; } /* ----------------------------------------------------------------------------- @@ -3820,7 +3829,7 @@ public: Node *disconn_attr = NewHash(); String *disconn_methodname = NULL; - disconn_tm = typemapLookup("directordisconnect", full_classname, WARN_NONE, disconn_attr); + disconn_tm = typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr); disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname"); Printv(w->code, "}\n", NIL); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 4f393b839..ea24f34d1 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1171,11 +1171,11 @@ public: // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum // Pure Java baseclass and interfaces - const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE); - const String *pure_interfaces = typemapLookup("javainterfaces", typemap_lookup_type, WARN_NONE); + const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE); + const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE); // Emit the enum - Printv(enum_code, typemapLookup("javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really) + Printv(enum_code, typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really) " ", symname, *Char(pure_baseclass) ? // Bases " extends " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces " implements " : "", pure_interfaces, " {\n", NIL); @@ -1196,8 +1196,8 @@ public: // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum // Finish the enum declaration // Typemaps are used to generate the enum definition in a similar manner to proxy classes. - Printv(enum_code, (enum_feature == ProperEnum) ? ";\n" : "", typemapLookup("javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class - typemapLookup("javacode", typemap_lookup_type, WARN_NONE), // extra Java code + Printv(enum_code, (enum_feature == ProperEnum) ? ";\n" : "", typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class + typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code "}", NIL); Replaceall(enum_code, "$javaclassname", symname); @@ -1234,7 +1234,7 @@ public: if (Len(package) > 0) Printf(f_enum, "package %s;\n", package); - Printv(f_enum, typemapLookup("javaimports", typemap_lookup_type, WARN_NONE), // Import statements + Printv(f_enum, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements "\n", enum_code, "\n", NIL); Printf(f_enum, "\n"); @@ -1295,7 +1295,7 @@ public: // Wrap C/C++ enums with constant integers or use the typesafe enum pattern const String *parent_name = Getattr(parentNode(n), "name"); String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int"); - const String *tm = typemapLookup("jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF); + const String *tm = typemapLookup(n, "jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF); String *return_type = Copy(tm); Delete(typemap_lookup_type); typemap_lookup_type = NULL; @@ -1560,12 +1560,12 @@ public: String *c_baseclass = NULL; String *baseclass = NULL; String *c_baseclassname = NULL; - String *typemap_lookup_type = Getattr(n, "classtypeobj"); + SwigType *typemap_lookup_type = Getattr(n, "classtypeobj"); bool feature_director = Swig_directorclass(n) ? true : false; // Inheritance from pure Java classes Node *attributes = NewHash(); - const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE, attributes); + const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE, attributes); bool purebase_replace = GetFlag(attributes, "tmap:javabase:replace") ? true : false; bool purebase_notderived = GetFlag(attributes, "tmap:javabase:notderived") ? true : false; Delete(attributes); @@ -1619,15 +1619,15 @@ public: } // Pure Java interfaces - const String *pure_interfaces = typemapLookup("javainterfaces", typemap_lookup_type, WARN_NONE); + const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE); // Start writing the proxy class - Printv(proxy_class_def, typemapLookup("javaimports", typemap_lookup_type, WARN_NONE), // Import statements - "\n", typemapLookup("javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers + Printv(proxy_class_def, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements + "\n", typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " $javaclassname", // Class name and bases (*Char(wanted_base)) ? " extends " : "", wanted_base, *Char(pure_interfaces) ? // Pure Java interfaces - " implements " : "", pure_interfaces, " {", derived ? typemapLookup("javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class - typemapLookup("javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class + " implements " : "", pure_interfaces, " {", derived ? typemapLookup(n, "javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class + typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class NIL); // C++ destructor is wrapped by the delete method @@ -1638,11 +1638,11 @@ public: String *destruct_methodname = NULL; String *destruct_methodmodifiers = NULL; if (derived) { - tm = typemapLookup("javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes); + tm = typemapLookup(n, "javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:javadestruct_derived:methodname"); destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct_derived:methodmodifiers"); } else { - tm = typemapLookup("javadestruct", typemap_lookup_type, WARN_NONE, attributes); + tm = typemapLookup(n, "javadestruct", typemap_lookup_type, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:javadestruct:methodname"); destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct:methodmodifiers"); } @@ -1660,7 +1660,7 @@ public: if (tm) { // Finalize method if (*Char(destructor_call)) { - Printv(proxy_class_def, typemapLookup("javafinalize", typemap_lookup_type, WARN_NONE), NIL); + Printv(proxy_class_def, typemapLookup(n, "javafinalize", typemap_lookup_type, WARN_NONE), NIL); } // delete method Printv(destruct, tm, NIL); @@ -1681,9 +1681,9 @@ public: release_jnicall = NewStringf("%s.%s_change_ownership(this, swigCPtr, false)", imclass_name, proxy_class_name); take_jnicall = NewStringf("%s.%s_change_ownership(this, swigCPtr, true)", imclass_name, proxy_class_name); - emitCodeTypemap(false, typemap_lookup_type, "directordisconnect", "methodname", destruct_jnicall); - emitCodeTypemap(false, typemap_lookup_type, "directorowner_release", "methodname", release_jnicall); - emitCodeTypemap(false, typemap_lookup_type, "directorowner_take", "methodname", take_jnicall); + emitCodeTypemap(n, false, typemap_lookup_type, "directordisconnect", "methodname", destruct_jnicall); + emitCodeTypemap(n, false, typemap_lookup_type, "directorowner_release", "methodname", release_jnicall); + emitCodeTypemap(n, false, typemap_lookup_type, "directorowner_take", "methodname", take_jnicall); Delete(destruct_jnicall); Delete(release_jnicall); @@ -1694,7 +1694,7 @@ public: Delete(destruct); // Emit extra user code - Printv(proxy_class_def, typemapLookup("javacode", typemap_lookup_type, WARN_NONE), // extra Java code + Printv(proxy_class_def, typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code "\n", NIL); // Substitute various strings into the above template @@ -2285,7 +2285,7 @@ public: /* Insert the javaconstruct typemap, doing the replacement for $directorconnect, as needed */ Hash *attributes = NewHash(); - String *construct_tm = Copy(typemapLookup("javaconstruct", Getattr(n, "name"), + String *construct_tm = Copy(typemapLookup(n, "javaconstruct", Getattr(n, "name"), WARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF, attributes)); if (construct_tm) { if (!feature_director) { @@ -2815,6 +2815,10 @@ public: * ----------------------------------------------------------------------------- */ void emitTypeWrapperClass(String *classname, SwigType *type) { + Node *n = NewHash(); + Setfile(n, input_file); + Setline(n, line_number); + String *swigtype = NewString(""); String *filen = NewStringf("%s%s.java", SWIG_output_directory(), classname); File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); @@ -2833,16 +2837,16 @@ public: Printf(f_swigtype, "package %s;\n", package); // Pure Java baseclass and interfaces - const String *pure_baseclass = typemapLookup("javabase", type, WARN_NONE); - const String *pure_interfaces = typemapLookup("javainterfaces", type, WARN_NONE); + const String *pure_baseclass = typemapLookup(n, "javabase", type, WARN_NONE); + const String *pure_interfaces = typemapLookup(n, "javainterfaces", type, WARN_NONE); // Emit the class - Printv(swigtype, typemapLookup("javaimports", type, WARN_NONE), // Import statements - "\n", typemapLookup("javaclassmodifiers", type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers + Printv(swigtype, typemapLookup(n, "javaimports", type, WARN_NONE), // Import statements + "\n", typemapLookup(n, "javaclassmodifiers", type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " $javaclassname", // Class name and bases *Char(pure_baseclass) ? " extends " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces - " implements " : "", pure_interfaces, " {", typemapLookup("javabody", type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class - typemapLookup("javacode", type, WARN_NONE), // extra Java code + " implements " : "", pure_interfaces, " {", typemapLookup(n, "javabody", type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class + typemapLookup(n, "javacode", type, WARN_NONE), // extra Java code "}\n", "\n", NIL); Replaceall(swigtype, "$javaclassname", classname); @@ -2852,29 +2856,34 @@ public: Close(f_swigtype); Delete(swigtype); + Delete(n); } /* ----------------------------------------------------------------------------- * typemapLookup() + * n - for input only and must contain info for Getfile(n) and Getline(n) to work + * op - typemap method name + * type - typemap type to lookup + * warning - warning number to issue if no typemaps found + * typemap_attributes - the typemap attributes are attached to this node and will + * also be used for temporary storage if non null + * return is never NULL, unlike Swig_typemap_lookup() * ----------------------------------------------------------------------------- */ - const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) { - String *tm = NULL; - const String *code = NULL; - - if ((tm = Swig_typemap_search(op, type, NULL, NULL))) { - code = Getattr(tm, "code"); - if (typemap_attributes) - Swig_typemap_attach_kwargs(tm, op, typemap_attributes); - } - - if (!code) { - code = empty_string; + const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) { + Node *node = !typemap_attributes ? NewHash() : typemap_attributes; + Setattr(node, "type", type); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *tm = Swig_typemap_lookup(op, node, "", 0); + if (!tm) { + tm = empty_string; if (warning != WARN_NONE) - Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type); + Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0)); } - - return code ? code : empty_string; + if (!typemap_attributes) + Delete(node); + return tm; } /* ----------------------------------------------------------------------------- @@ -3183,8 +3192,7 @@ public: * typemaps. *--------------------------------------------------------------------*/ - void - emitCodeTypemap(bool derived, String *lookup_type, const String *typemap, const String *methodname, const String *jnicall) { + void emitCodeTypemap(Node *n, bool derived, SwigType *lookup_type, const String *typemap, const String *methodname, const String *jnicall) { const String *tm = NULL; Node *tmattrs = NewHash(); String *lookup_tmname = NewString(typemap); @@ -3195,7 +3203,7 @@ public: Append(lookup_tmname, "_derived"); } - tm = typemapLookup(lookup_tmname, lookup_type, WARN_NONE, tmattrs); + tm = typemapLookup(n, lookup_tmname, lookup_type, WARN_NONE, tmattrs); method_attr_name = NewStringf("tmap:%s:%s", lookup_tmname, methodname); method_attr = Getattr(tmattrs, method_attr_name); @@ -3979,7 +3987,7 @@ public: Node *disconn_attr = NewHash(); String *disconn_methodname = NULL; - disconn_tm = typemapLookup("directordisconnect", full_classname, WARN_NONE, disconn_attr); + disconn_tm = typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr); disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname"); Printv(w->code, " swig_disconnect_director_self(\"", disconn_methodname, "\");\n", "}\n", NIL); diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index b3568c0bf..5445d0761 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -2230,23 +2230,23 @@ MODULA3(): baseclass = NewString(""); // Inheritance from pure Modula 3 classes - const String *pure_baseclass = typemapLookup("m3base", classDeclarationName, WARN_NONE); + const String *pure_baseclass = typemapLookup(n, "m3base", classDeclarationName, WARN_NONE); if (hasContent(pure_baseclass) && hasContent(baseclass)) { Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file, line_number, "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", classDeclarationName, pure_baseclass); } // Pure Modula 3 interfaces - const String *pure_interfaces = typemapLookup(derived ? "m3interfaces_derived" : "m3interfaces", + const String *pure_interfaces = typemapLookup(n, derived ? "m3interfaces_derived" : "m3interfaces", classDeclarationName, WARN_NONE); // Start writing the proxy class - Printv(proxy_class_def, typemapLookup("m3imports", classDeclarationName, WARN_NONE), // Import statements - "\n", typemapLookup("m3classmodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers + Printv(proxy_class_def, typemapLookup(n, "m3imports", classDeclarationName, WARN_NONE), // Import statements + "\n", typemapLookup(n, "m3classmodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " class $m3classname", // Class name and bases (derived || *Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", baseclass, pure_baseclass, ((derived || *Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces ", " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", // Member variables for memory handling - derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup("m3ptrconstructormodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers + derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers " $m3classname(IntPtr cPtr, bool cMemoryOwn) ", // Constructor used for wrapping pointers derived ? ": base($imclassname.$m3classnameTo$baseclass(cPtr), cMemoryOwn) {\n" @@ -2262,10 +2262,10 @@ MODULA3(): Node *attributes = NewHash(); String *destruct_methodname = NULL; if (derived) { - tm = typemapLookup("m3destruct_derived", classDeclarationName, WARN_NONE, attributes); + tm = typemapLookup(n, "m3destruct_derived", classDeclarationName, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:m3destruct_derived:methodname"); } else { - tm = typemapLookup("m3destruct", classDeclarationName, WARN_NONE, attributes); + tm = typemapLookup(n, "m3destruct", classDeclarationName, WARN_NONE, attributes); destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname"); } if (!destruct_methodname) { @@ -2275,7 +2275,7 @@ MODULA3(): if (tm) { // Finalize method if (*Char(destructor_call)) { - Printv(proxy_class_def, typemapLookup("m3finalize", classDeclarationName, WARN_NONE), NIL); + Printv(proxy_class_def, typemapLookup(n, "m3finalize", classDeclarationName, WARN_NONE), NIL); } // Dispose method Printv(destruct, tm, NIL); @@ -2290,8 +2290,8 @@ MODULA3(): Delete(destruct); // Emit various other methods - Printv(proxy_class_def, typemapLookup("m3getcptr", classDeclarationName, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method - typemapLookup("m3code", classDeclarationName, WARN_NONE), // extra Modula 3 code + Printv(proxy_class_def, typemapLookup(n, "m3getcptr", classDeclarationName, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method + typemapLookup(n, "m3code", classDeclarationName, WARN_NONE), // extra Modula 3 code "\n", NIL); // Substitute various strings into the above template @@ -3765,6 +3765,10 @@ MODULA3(): * ----------------------------------------------------------------------------- */ void emitTypeWrapperClass(String *classname, SwigType *type) { + Node *n = NewHash(); + Setfile(n, input_file); + Setline(n, line_number); + String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), classname); File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); if (!f_swigtype) { @@ -3777,19 +3781,19 @@ MODULA3(): emitBanner(f_swigtype); // Pure Modula 3 baseclass and interfaces - const String *pure_baseclass = typemapLookup("m3base", type, WARN_NONE); - const String *pure_interfaces = typemapLookup("m3interfaces", type, WARN_NONE); + const String *pure_baseclass = typemapLookup(n, "m3base", type, WARN_NONE); + const String *pure_interfaces = typemapLookup(n, "m3interfaces", type, WARN_NONE); // Emit the class - Printv(swigtype, typemapLookup("m3imports", type, WARN_NONE), // Import statements - "\n", typemapLookup("m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers + Printv(swigtype, typemapLookup(n, "m3imports", type, WARN_NONE), // Import statements + "\n", typemapLookup(n, "m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers " class $m3classname", // Class name and bases *Char(pure_baseclass) ? " : " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces - " : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup("m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers + " : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers " $m3classname(IntPtr cPtr, bool bFutureUse) {\n", // Constructor used for wrapping pointers " swigCPtr = cPtr;\n", " }\n", "\n", " protected $m3classname() {\n", // Default constructor - " swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup("m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method - typemapLookup("m3code", type, WARN_NONE), // extra Modula 3 code + " swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup(n, "m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method + typemapLookup(n, "m3code", type, WARN_NONE), // extra Modula 3 code "}\n", "\n", NIL); Replaceall(swigtype, "$m3classname", classname); @@ -3802,25 +3806,29 @@ MODULA3(): /* ----------------------------------------------------------------------------- * typemapLookup() + * n - for input only and must contain info for Getfile(n) and Getline(n) to work + * op - typemap method name + * type - typemap type to lookup + * warning - warning number to issue if no typemaps found + * typemap_attributes - the typemap attributes are attached to this node and will + * also be used for temporary storage if non null + * return is never NULL, unlike Swig_typemap_lookup() * ----------------------------------------------------------------------------- */ - const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) { - String *tm = NULL; - const String *code = NULL; - - if ((tm = Swig_typemap_search(op, type, NULL, NULL))) { - code = Getattr(tm, "code"); - if (typemap_attributes) - Swig_typemap_attach_kwargs(tm, op, typemap_attributes); - } - - if (!code) { - code = empty_string; + const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) { + Node *node = !typemap_attributes ? NewHash() : typemap_attributes; + Setattr(node, "type", type); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *tm = Swig_typemap_lookup(op, node, "", 0); + if (!tm) { + tm = empty_string; if (warning != WARN_NONE) - Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type); + Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0)); } - - return code ? code : empty_string; + if (!typemap_attributes) + Delete(node); + return tm; } /* ----------------------------------------------------------------------------- diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index d3f8401f0..44ec972de 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -131,11 +131,17 @@ static void add_defined_foreign_type(String *type) { } -static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) { - Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0); - if (typemap) { - String *typespec = Getattr(typemap, "code"); - return NewString(typespec); +static String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) { + Node *node = NewHash(); + Setattr(node, "type", ty); + Setattr(node, "name", name); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *tm = Swig_typemap_lookup("ffitype", node, "", 0); + Delete(node); + + if (tm) { + return NewString(tm); } else { SwigType *tr = SwigType_typedef_resolve_all(ty); char *type_reduced = Char(tr); @@ -167,14 +173,16 @@ static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) { return 0; } -static String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) { - Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0); - if (typemap) { - String *typespec = Getattr(typemap, "code"); - return NewString(typespec); - } else { - return NewString(""); - } +static String *get_lisp_type(Node *n, SwigType *ty, const_String_or_char_ptr name) { + Node *node = NewHash(); + Setattr(node, "type", ty); + Setattr(node, "name", name); + Setfile(node, Getfile(n)); + Setline(node, Getline(n)); + const String *tm = Swig_typemap_lookup("lisptype", node, "", 0); + Delete(node); + + return tm ? NewString(tm) : NewString(""); } void UFFI::main(int argc, char *argv[]) { @@ -280,8 +288,8 @@ int UFFI::functionWrapper(Node *n) { for (p = pl; p; p = nextSibling(p), argnum++) { String *argname = Getattr(p, "name"); SwigType *argtype = Getattr(p, "type"); - String *ffitype = get_ffi_type(argtype, argname); - String *lisptype = get_lisp_type(argtype, argname); + String *ffitype = get_ffi_type(n, argtype, argname); + String *lisptype = get_lisp_type(n, argtype, argname); int tempargname = 0; if (!argname) { @@ -307,7 +315,7 @@ int UFFI::functionWrapper(Node *n) { //" :strings-convert t\n" //" :call-direct %s\n" //" :optimize-for-space t" - ")\n", get_ffi_type(Getattr(n, "type"), "result") + ")\n", get_ffi_type(n, Getattr(n, "type"), "result") //,varargs ? "nil" : "t" ); @@ -361,7 +369,7 @@ int UFFI::classHandler(Node *n) { /* Printf(stdout, "Converting %s in %s\n", type, name); */ - lisp_type = get_ffi_type(type, Getattr(c, "sym:name")); + lisp_type = get_ffi_type(n, type, Getattr(c, "sym:name")); Printf(f_cl, " (#.(%s \"%s\" :type :slot) %s)\n", identifier_converter, Getattr(c, "sym:name"), lisp_type); diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 2b2c797c9..68e7d3a10 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -370,11 +370,8 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Swig_typemap_clear_apply(ParmList *pattern); extern void Swig_typemap_debug(void); - extern Hash *Swig_typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr pname, SwigType **matchtype); - extern Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch); extern String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f); extern String *Swig_typemap_lookup_out(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode); - extern void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p); extern void Swig_typemap_new_scope(void); extern Hash *Swig_typemap_pop_scope(void); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 401a99801..fd4e42579 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -114,7 +114,7 @@ static String *tmop_name(const_String_or_char_ptr op) { we have to make sure that we only intern strings without object identity into the hash table. - (Swig_typemap_attach_kwargs calls tmop_name several times with + (typemap_attach_kwargs calls tmop_name several times with the "same" String *op (i.e., same object identity) but differing string values.) @@ -134,6 +134,7 @@ static String *tmop_name(const_String_or_char_ptr op) { return s; } +#if 0 /* ----------------------------------------------------------------------------- * Swig_typemap_new_scope() * @@ -157,6 +158,7 @@ Hash *Swig_typemap_pop_scope() { } return 0; } +#endif /* ----------------------------------------------------------------------------- * Swig_typemap_register() @@ -265,12 +267,12 @@ void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_S } /* ----------------------------------------------------------------------------- - * Swig_typemap_get() + * typemap_get() * * Retrieve typemap information from current scope. * ----------------------------------------------------------------------------- */ -static Hash *Swig_typemap_get(SwigType *type, const_String_or_char_ptr name, int scope) { +static Hash *typemap_get(SwigType *type, const_String_or_char_ptr name, int scope) { Hash *tm, *tm1; /* See if this type has been seen before */ if ((scope < 0) || (scope > tm_scope)) @@ -312,7 +314,7 @@ int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList pname = Getattr(p, "name"); /* Lookup the type */ - tm = Swig_typemap_get(ptype, pname, ts); + tm = typemap_get(ptype, pname, ts); if (!tm) break; @@ -360,7 +362,7 @@ void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) { while (p) { type = Getattr(p, "type"); name = Getattr(p, "name"); - tm = Swig_typemap_get(type, name, tm_scope); + tm = typemap_get(type, name, tm_scope); if (!tm) return; p = nextSibling(p); @@ -385,8 +387,7 @@ void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) { * it works. * ----------------------------------------------------------------------------- */ -static -int count_args(String *s) { +static int count_args(String *s) { /* Count up number of arguments */ int na = 0; char *c = Char(s); @@ -456,7 +457,7 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) { while (ts >= 0) { /* See if there is a matching typemap in this scope */ - sm = Swig_typemap_get(type, name, ts); + sm = typemap_get(type, name, ts); /* if there is not matching, look for a typemap in the original typedef, if any, like in: @@ -468,7 +469,7 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) { if (!sm) { SwigType *ntype = SwigType_typedef_resolve(type); if (ntype && (Cmp(ntype, type) != 0)) { - sm = Swig_typemap_get(ntype, name, ts); + sm = typemap_get(ntype, name, ts); } Delete(ntype); } @@ -584,13 +585,13 @@ static SwigType *strip_arrays(SwigType *type) { } /* ----------------------------------------------------------------------------- - * Swig_typemap_search() + * typemap_search() * * Search for a typemap match. Tries to find the most specific typemap * that includes a 'code' attribute. * ----------------------------------------------------------------------------- */ -Hash *Swig_typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr name, SwigType **matchtype) { +static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr name, SwigType **matchtype) { Hash *result = 0, *tm, *tm1, *tma; Hash *backup = 0; SwigType *noarrays = 0; @@ -732,12 +733,12 @@ ret_result: /* ----------------------------------------------------------------------------- - * Swig_typemap_search_multi() + * typemap_search_multi() * * Search for a multi-valued typemap. * ----------------------------------------------------------------------------- */ -Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch) { +static Hash *typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch) { SwigType *type; SwigType *mtype = 0; String *name; @@ -752,14 +753,14 @@ Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, in name = Getattr(parms, "name"); /* Try to find a match on the first type */ - tm = Swig_typemap_search(op, type, name, &mtype); + tm = typemap_search(op, type, name, &mtype); if (tm) { if (mtype && SwigType_isarray(mtype)) { Setattr(parms, "tmap:match", mtype); } Delete(mtype); newop = NewStringf("%s-%s+%s:", op, type, name); - tm1 = Swig_typemap_search_multi(newop, nextSibling(parms), nmatch); + tm1 = typemap_search_multi(newop, nextSibling(parms), nmatch); if (tm1) tm = tm1; if (Getattr(tm, "code")) { @@ -780,8 +781,7 @@ Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, in * type and pname are the type and parameter name. * ----------------------------------------------------------------------------- */ -static -void replace_local_types(ParmList *p, const String *name, const String *rep) { +static void replace_local_types(ParmList *p, const String *name, const String *rep) { SwigType *t; while (p) { t = Getattr(p, "type"); @@ -790,8 +790,7 @@ void replace_local_types(ParmList *p, const String *name, const String *rep) { } } -static -int check_locals(ParmList *p, const char *s) { +static int check_locals(ParmList *p, const char *s) { while (p) { char *c = GetChar(p, "type"); if (strstr(c, s)) @@ -801,8 +800,7 @@ int check_locals(ParmList *p, const char *s) { return 0; } -static -int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, SwigType *rtype, String *pname, String *lname, int index) { +static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, SwigType *rtype, String *pname, String *lname, int index) { char var[512]; char *varname; SwigType *ftype; @@ -1216,7 +1214,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, String *qsn = st ? Swig_symbol_string_qualify(pname, st) : 0; if (qsn) { if (Len(qsn) && !Equal(qsn, pname)) { - tm = Swig_typemap_search(op, type, qsn, &mtype); + tm = typemap_search(op, type, qsn, &mtype); if (tm && (!Getattr(tm, "pname") || strstr(Char(Getattr(tm, "type")), "SWIGTYPE"))) { tm = 0; } @@ -1226,7 +1224,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, } if (!tm) #endif - tm = Swig_typemap_search(op, type, pname, &mtype); + tm = typemap_search(op, type, pname, &mtype); if (!tm) return sdef; @@ -1394,9 +1392,8 @@ String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *node, const_Strin return Swig_typemap_lookup_impl(op, node, lname, f, 0); } - /* ----------------------------------------------------------------------------- - * Swig_typemap_attach_kwargs() + * typemap_attach_kwargs() * * If this hash (tm) contains a linked list of parameters under its "kwargs" * attribute, add keys for each of those named keyword arguments to this @@ -1406,7 +1403,7 @@ String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *node, const_Strin * A new attribute called "tmap:in:foo" with value "xyz" is attached to p. * ----------------------------------------------------------------------------- */ -void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p) { +static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p) { String *temp = NewStringEmpty(); Parm *kw = Getattr(tm, "kwargs"); while (kw) { @@ -1432,13 +1429,13 @@ void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p) } /* ----------------------------------------------------------------------------- - * Swig_typemap_warn() + * typemap_warn() * * If any warning message is attached to this parameter's "tmap:op:warning" * attribute, print that warning message. * ----------------------------------------------------------------------------- */ -static void Swig_typemap_warn(const_String_or_char_ptr op, Parm *p) { +static void typemap_warn(const_String_or_char_ptr op, Parm *p) { String *temp = NewStringf("%s:warning", op); String *w = Getattr(p, tmop_name(temp)); Delete(temp); @@ -1447,7 +1444,7 @@ static void Swig_typemap_warn(const_String_or_char_ptr op, Parm *p) { } } -static void Swig_typemap_emit_code_fragments(const_String_or_char_ptr op, Parm *p) { +static void typemap_emit_code_fragments(const_String_or_char_ptr op, Parm *p) { String *temp = NewStringf("%s:fragment", op); String *f = Getattr(p, tmop_name(temp)); if (f) { @@ -1467,7 +1464,7 @@ static void Swig_typemap_emit_code_fragments(const_String_or_char_ptr op, Parm * * given typemap type * ----------------------------------------------------------------------------- */ -String *Swig_typemap_get_option(Hash *tm, const_String_or_char_ptr name) { +static String *typemap_get_option(Hash *tm, const_String_or_char_ptr name) { Parm *kw = Getattr(tm, "kwargs"); while (kw) { String *kname = Getattr(kw, "name"); @@ -1502,7 +1499,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra #ifdef SWIG_DEBUG Printf(stdout, "parms: %s %s %s\n", op, Getattr(p, "name"), Getattr(p, "type")); #endif - tm = Swig_typemap_search_multi(op, p, &nmatch); + tm = typemap_search_multi(op, p, &nmatch); #ifdef SWIG_DEBUG if (tm) Printf(stdout, "found: %s\n", tm); @@ -1521,7 +1518,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra here, the freearg typemap requires the "in" typemap to match, or the 'var$argnum' variable will not exist. */ - kwmatch = Swig_typemap_get_option(tm, "match"); + kwmatch = typemap_get_option(tm, "match"); if (kwmatch) { String *tmname = NewStringf("tmap:%s", kwmatch); String *tmin = Getattr(p, tmname); @@ -1547,7 +1544,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra continue; } else { int nnmatch; - Hash *tmapin = Swig_typemap_search_multi(kwmatch, p, &nnmatch); + Hash *tmapin = typemap_search_multi(kwmatch, p, &nnmatch); String *tmname = Getattr(tm, "pname"); String *tnname = Getattr(tmapin, "pname"); if (!(tmname && tnname && Equal(tmname, tnname)) && !(!tmname && !tnname)) { @@ -1640,13 +1637,13 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra Setattr(firstp, tmop_name(temp), p); /* Attach kwargs */ - Swig_typemap_attach_kwargs(tm, op, firstp); + typemap_attach_kwargs(tm, op, firstp); /* Print warnings, if any */ - Swig_typemap_warn(op, firstp); + typemap_warn(op, firstp); /* Look for code fragments */ - Swig_typemap_emit_code_fragments(op, firstp); + typemap_emit_code_fragments(op, firstp); /* increase argnum to consider numinputs */ argnum += nmatch - 1; From 0576ffcde7ecc664848e77219f6709bde86dff6b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 9 Jul 2009 19:56:47 +0000 Subject: [PATCH 041/352] add test for %extend on member variable git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11382 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 3 ++- .../java/memberin_extend_runme.java | 26 +++++++++++++++++++ Examples/test-suite/memberin_extend.i | 22 ++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/java/memberin_extend_runme.java create mode 100644 Examples/test-suite/memberin_extend.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 74baddc81..ec52f29e3 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -79,7 +79,7 @@ CPP_TEST_BROKEN += \ extend_variable \ li_std_vector_ptr \ namespace_union \ - nested_struct \ + nested_structs \ overload_complicated \ template_default_pointer \ template_expr @@ -220,6 +220,7 @@ CPP_TEST_CASES += \ li_typemaps \ li_windows \ long_long_apply \ + memberin_extend \ member_pointer \ member_template \ minherit \ diff --git a/Examples/test-suite/java/memberin_extend_runme.java b/Examples/test-suite/java/memberin_extend_runme.java new file mode 100644 index 000000000..c3fa29d8d --- /dev/null +++ b/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/Examples/test-suite/memberin_extend.i b/Examples/test-suite/memberin_extend.i new file mode 100644 index 000000000..f20617b66 --- /dev/null +++ b/Examples/test-suite/memberin_extend.i @@ -0,0 +1,22 @@ +%module memberin_extend + +// Tests memberin typemap. The default char * memberin typemap will be used. +// The test extends the struct with a pseudo member variable + +%inline %{ +#include +struct ExtendMe { +}; +%} + +%{ +#include +std::map ExtendMeStringMap; +#define ExtendMe_thing_set(self_, val_) ExtendMeStringMap[self_] +#define ExtendMe_thing_get(self_) ExtendMeStringMap[self_] +%} + +%extend ExtendMe { + char *thing; +} + From cdc9de82104dcb3df4450ace3a843359476718cf Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Sun, 12 Jul 2009 20:23:19 +0000 Subject: [PATCH 042/352] small fixes to make octave module compatible with octave 3.2 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11388 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/octave/empty_runme.m | 14 ++++++++++++++ Lib/octave/octrun.swg | 10 ++++++++++ Lib/octave/octruntime.swg | 21 +++++++++++++++++++++ Source/Modules/octave.cxx | 16 +++++++++++++++- 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/octave/empty_runme.m b/Examples/test-suite/octave/empty_runme.m index c6cac6926..e5b2593d4 100644 --- a/Examples/test-suite/octave/empty_runme.m +++ b/Examples/test-suite/octave/empty_runme.m @@ -1 +1,15 @@ +printf("begin\n"); +who global empty +printf("after load\n"); +who global + +#clear -g +printf("after clear\n"); +who global + +#clear empty +printf("after clear specific\n"); +who global + +printf("before shutdown\n"); diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index c48310e27..16ba85878 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -439,9 +439,14 @@ namespace Swig { install_builtin_function(it->second.first->method, it->first, it->second.first->doc?it->second.first->doc:std::string()); else if (it->second.second.is_defined()) { +#if USE_OCTAVE_API_VERSION<37 link_to_global_variable(curr_sym_tab->lookup(it->first, true)); +#else + symbol_table::mark_global(it->first); +#endif set_global_value(it->first, it->second.second); +#if USE_OCTAVE_API_VERSION<37 octave_swig_type *ost = Swig::swig_value_deref(it->second.second); if (ost) { const char* h = ost->help_text(); @@ -450,6 +455,7 @@ namespace Swig { sr->document(h); } } +#endif } } } @@ -1352,6 +1358,10 @@ SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata) { SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *pointer) { octave_value ov = new octave_swig_packed(0, &pointer, sizeof(swig_module_info *)); const char *module_var = "__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION; +#if USE_OCTAVE_API_VERSION<37 link_to_global_variable(curr_sym_tab->lookup(module_var, true)); +#else + symbol_table::mark_global(module_var); +#endif set_global_value(module_var, ov); } diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index 82a17285a..75b4f1194 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -72,11 +72,32 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) { module_ns->install_global(); module_ns->decref(); +#if USE_OCTAVE_API_VERSION<37 link_to_global_variable(curr_sym_tab->lookup(SWIG_name_d,true)); +#else + symbol_table::mark_global(SWIG_name_d); +#endif set_global_value(SWIG_name_d,Swig::swig_value_ref(module_ns)); +#if USE_OCTAVE_API_VERSION>=37 + mlock(); +#endif + return octave_value_list(); } +// workaround bug in octave where installing global variable of custom type and then +// exiting without explicitly clearing the variable causes octave to segfault. +#if USE_OCTAVE_API_VERSION>=37 +struct oct_file_unload { + ~oct_file_unload() { + string_vector vars = symbol_table::global_variable_names(); + for (int i = 0; i < vars.length(); i++) + symbol_table::clear_global(vars[i]); + } +}; +static oct_file_unload __unload; +#endif + %} diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 55ffe8cbb..e65cc1cfa 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -13,7 +13,8 @@ char cvsroot_octave_cxx[] = "$Id$"; static const char *usage = (char *) "\ Octave Options (available with -octave)\n\ - (none yet)\n\n"; + -api - Generate code that assume octave API N [default: 37]\n\ + \n"; class OCTAVE:public Language { @@ -35,6 +36,8 @@ private: int have_destructor; String *constructor_name; + int api_version; + Hash *docs; public: @@ -53,6 +56,7 @@ public: director_multiple_inheritance = 1; director_language = 1; docs = NewHash(); + api_version = 37; } virtual void main(int argc, char *argv[]) { @@ -60,6 +64,15 @@ public: if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { fputs(usage, stderr); + } else if (strcmp(argv[i], "-api") == 0) { + if (argv[i + 1]) { + api_version = atoi(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } } } } @@ -125,6 +138,7 @@ public: Printf(f_runtime, "#define SWIGOCTAVE\n"); Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module); Printf(f_runtime, "#define SWIG_name %s\n", module); + Printf(f_runtime, "#define USE_OCTAVE_API_VERSION %i\n", api_version); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); From 68d0177d6c44de05fce1b0e920d6df9dc8953ad2 Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Sun, 12 Jul 2009 21:09:50 +0000 Subject: [PATCH 043/352] more fixes for octave 3.2 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11389 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/octave/empty_runme.m | 4 +++- Lib/octave/octrun.swg | 24 +++++++++++++++++------- Lib/octave/octruntime.swg | 1 + 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Examples/test-suite/octave/empty_runme.m b/Examples/test-suite/octave/empty_runme.m index e5b2593d4..373c7b0dd 100644 --- a/Examples/test-suite/octave/empty_runme.m +++ b/Examples/test-suite/octave/empty_runme.m @@ -1,6 +1,8 @@ +empty + printf("begin\n"); who global -empty + printf("after load\n"); who global diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 16ba85878..759cf3c37 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -105,27 +105,35 @@ namespace Swig { typedef std::map < void *, Director * > rtdir_map; - SWIGINTERN rtdir_map &get_rtdir_map() { + SWIGINTERN rtdir_map* get_rtdir_map() { static swig_module_info *module = 0; if (!module) module = SWIG_GetModule(0); - assert(module); + if (!module) + return 0; if (!module->clientdata) module->clientdata = new rtdir_map; - return *(rtdir_map *) module->clientdata; + return (rtdir_map *) module->clientdata; } SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d) { - get_rtdir_map()[vptr] = d; + rtdir_map* rm = get_rtdir_map(); + if (rm) + (*rm)[vptr] = d; } SWIGINTERNINLINE void erase_rtdir(void *vptr) { - get_rtdir_map().erase(vptr); + rtdir_map* rm = get_rtdir_map(); + if (rm) + (*rm).erase(vptr); } SWIGINTERNINLINE Director *get_rtdir(void *vptr) { - rtdir_map::const_iterator pos = get_rtdir_map().find(vptr); - Director *rtdir = (pos != get_rtdir_map().end())? pos->second : 0; + rtdir_map* rm = get_rtdir_map(); + if (!rm) + return 0; + rtdir_map::const_iterator pos = rm->find(vptr); + Director *rtdir = (pos != rm->end())? pos->second : 0; return rtdir; } } @@ -442,6 +450,7 @@ namespace Swig { #if USE_OCTAVE_API_VERSION<37 link_to_global_variable(curr_sym_tab->lookup(it->first, true)); #else + symbol_table::varref(it->first); symbol_table::mark_global(it->first); #endif set_global_value(it->first, it->second.second); @@ -1361,6 +1370,7 @@ SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *point #if USE_OCTAVE_API_VERSION<37 link_to_global_variable(curr_sym_tab->lookup(module_var, true)); #else + symbol_table::varref(module_var); symbol_table::mark_global(module_var); #endif set_global_value(module_var, ov); diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index 75b4f1194..0ab7bd70b 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -75,6 +75,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) { #if USE_OCTAVE_API_VERSION<37 link_to_global_variable(curr_sym_tab->lookup(SWIG_name_d,true)); #else + symbol_table::varref(SWIG_name_d); symbol_table::mark_global(SWIG_name_d); #endif set_global_value(SWIG_name_d,Swig::swig_value_ref(module_ns)); From 3fb96c236444b549922e267183e800e73c3af47f Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Sun, 12 Jul 2009 21:11:08 +0000 Subject: [PATCH 044/352] fix typo git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11390 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/octave.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index e65cc1cfa..9f924332d 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -13,7 +13,7 @@ char cvsroot_octave_cxx[] = "$Id$"; static const char *usage = (char *) "\ Octave Options (available with -octave)\n\ - -api - Generate code that assume octave API N [default: 37]\n\ + -api - Generate code that assumes Octave API N [default: 37]\n\ \n"; From 9042e4d2f96665135b6b5e7119663f6e6005a52f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 13 Jul 2009 11:36:20 +0000 Subject: [PATCH 045/352] Document -const option. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11391 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Perl5.html | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index f77dc2f01..b5ad99769 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -815,7 +815,7 @@ extern char *path; // Declared later in the input

        -Constants are wrapped as read-only Perl variables. For example: +By default, constants are wrapped as read-only Perl variables. For example:

        @@ -838,6 +838,19 @@ $example::FOO = 2; # Error
        +

        +Alternatively, if you use swig's -const option, constants are wrapped +such that the leading $ isn't required (by using a constant subroutine), which +usually gives a more natural Perl interface, for example: +

        + +
        +
        +use example;
        +print example::FOO,"\n";
        +
        +
        +

        28.4.4 Pointers

        From 58088c7aab9209844523daddbbad71e6a900d1ad Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 13 Jul 2009 11:47:40 +0000 Subject: [PATCH 046/352] Sort out odd whitespace around HTML tags. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11392 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Perl5.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index b5ad99769..0579cddfd 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -40,7 +40,7 @@
      • Modules and packages
    2. Input and output parameters -
    3. Exception handling +
    4. Exception handling
    5. Remapping datatypes with typemaps
    6. Typemap Examples
        -
      • Converting a Perl5 array to a char ** -
      • Return values +
      • Converting a Perl5 array to a char ** +
      • Return values
      • Returning values from arguments
      • Accessing array structure members
      • Turning Perl references into C pointers @@ -892,7 +892,7 @@ if (defined($ptr)) {

        -To create a NULL pointer, you should pass the undef value to +To create a NULL pointer, you should pass the undef value to a function.

        @@ -902,7 +902,7 @@ pointer that SWIG wrapper functions return. Suppose that $a and $b are two references that point to the same C object. In general, $a and $b will be different--since they are different references. Thus, it is a mistake to check the equality -of $a and $b to check the equality of two C +of $a and $b to check the equality of two C pointers. The correct method to check equality of C pointers is to dereference them as follows :

        @@ -1580,7 +1580,7 @@ print "$c\n"; Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).

        -

        28.6 Exception handling

        +

        28.6 Exception handling

        @@ -2120,7 +2120,7 @@ might look at the files "perl5.swg" and "typemaps.i" in the SWIG library.

        -

        28.8.1 Converting a Perl5 array to a char **

        +

        28.8.1 Converting a Perl5 array to a char **

        @@ -2212,7 +2212,7 @@ print @$b,"\n"; # Print it out -

        28.8.2 Return values

        +

        28.8.2 Return values

        @@ -2727,7 +2727,7 @@ corresponding Perl object (this situation turns out to come up frequently when constructing objects like linked lists and trees). When C takes possession of an object, you can change Perl's ownership by simply deleting the object from the %OWNER hash. This is -done using the DISOWN method. +done using the DISOWN method.

        
        From c1399658ff2623f4910a08499240a464ef43d180 Mon Sep 17 00:00:00 2001
        From: Olly Betts 
        Date: Wed, 15 Jul 2009 07:43:16 +0000
        Subject: [PATCH 047/352] [Perl] Don't specify Perl prototype "()" for a
         constructor with a different name to the class, as such constructors can
         still take parameters.
        
        git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11397 626c5289-ae23-0410-ae9c-e8d60b6d4f22
        ---
         CHANGES.current          | 5 +++++
         Source/Modules/perl5.cxx | 2 +-
         2 files changed, 6 insertions(+), 1 deletion(-)
        
        diff --git a/CHANGES.current b/CHANGES.current
        index 06c0c8851..89057e97d 100644
        --- a/CHANGES.current
        +++ b/CHANGES.current
        @@ -1,6 +1,11 @@
         Version 1.3.40 (in progress)
         ============================
         
        +2009-07-15: olly
        +	    [Perl] Don't specify Perl prototype "()" for a constructor with a
        +	    different name to the class, as such constructors can still take
        +	    parameters.
        +
         2009-07-05: olly
         	    [PHP] Update the list of PHP keywords - "cfunction" is no longer a
         	    keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__",
        diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx
        index eace179a7..177571dea 100644
        --- a/Source/Modules/perl5.cxx
        +++ b/Source/Modules/perl5.cxx
        @@ -1511,7 +1511,7 @@ public:
         	  Printf(pcode, "sub new {\n");
         	} else {
         	  /* Constructor doesn't match classname so we'll just use the normal name  */
        -	  Printv(pcode, "sub ", Swig_name_construct(symname), " () {\n", NIL);
        +	  Printv(pcode, "sub ", Swig_name_construct(symname), " {\n", NIL);
         	}
         
         	Printv(pcode,
        
        From 389cb8e7f38b28292b3f8547e95df8881817e64a Mon Sep 17 00:00:00 2001
        From: William S Fulton 
        Date: Sat, 18 Jul 2009 22:26:35 +0000
        Subject: [PATCH 048/352] Mention Return Value Optimization when using the
         optimal attribute in the out typemap
        
        git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11420 626c5289-ae23-0410-ae9c-e8d60b6d4f22
        ---
         Doc/Manual/Typemaps.html | 11 ++++++-----
         1 file changed, 6 insertions(+), 5 deletions(-)
        
        diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
        index 777184069..8137bfcfe 100644
        --- a/Doc/Manual/Typemaps.html
        +++ b/Doc/Manual/Typemaps.html
        @@ -2636,8 +2636,9 @@ The example above also shows a common approach of issuing a warning for an as ye
         

        The "out" typemap is the main typemap for return types. This typemap supports an optional attribute flag called "optimal", which is for reducing -temporary variables and the amount of generated code. -It only really makes a difference when returning objects by value and it cannot always be used, +temporary variables and the amount of generated code, thereby giving the compiler the opportunity to +use return value optimization for generating faster executing code. +It only really makes a difference when returning objects by value and has some limitations on usage, as explained later on.

        @@ -2695,7 +2696,7 @@ XX(const XX &) Note that three objects are being created as well as an assignment. Wouldn't it be great if the XX::create() method was the only time a constructor was called? As the method returns by value, this is asking a lot and the code that SWIG generates by default -makes it impossible for the compiler to make this type of optimisation. +makes it impossible for the compiler to use return value optimisation (RVO). However, this is where the "optimal" attribute in the "out" typemap can help out. If the typemap code is kept the same and just the "optimal" attribute specified like this:

        @@ -2754,7 +2755,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_XX_create() {

        The major difference is the result temporary variable holding the value returned from XX::create() is no longer generated and instead the copy constructor call is made directly from the value returned by XX::create(). -With modern compiler optimisations turned on, the copy is not actually done, in fact the object is never created +With modern compilers implementing RVO, the copy is not actually done, in fact the object is never created on the stack in XX::create() at all, it is simply created directly on the heap. In the first instance, the $1 special variable in the typemap is expanded into result. In the second instance, $1 is expanded into XX::create() and this is essentially @@ -2762,7 +2763,7 @@ what the "optimal" attribute is telling SWIG to do.

        -This kind of optimisation is not turned on by default as it has a number of restrictions. +The "optimal" attribute optimisation is not turned on by default as it has a number of restrictions. Firstly, some code cannot be condensed into a simple call for passing into the copy constructor. One common occurrence is when %exception is used. Consider adding the following %exception to the example: From 8ec7035eee6e542b824e5f988a3fd1ce1a8eb10c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 18 Jul 2009 22:34:33 +0000 Subject: [PATCH 049/352] improve WARN_LANG_OVERLOAD_KEYWORD warning by giving the name of the overloaded function git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11421 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/python.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 73f280e6b..a5ffe294e 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1913,7 +1913,7 @@ public: Printv(f->def, "SWIGINTERN PyObject *", wname, "__varargs__", "(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *varargs) {", NIL); } if (allow_kwargs) { - Swig_warning(WARN_LANG_OVERLOAD_KEYWORD, input_file, line_number, "Can't use keyword arguments with overloaded functions.\n"); + Swig_warning(WARN_LANG_OVERLOAD_KEYWORD, input_file, line_number, "Can't use keyword arguments with overloaded functions (%s).\n", Swig_name_decl(n)); allow_kwargs = 0; } } else { From 0249eea38995dfc6689c78cde861b7ec2b6b4af2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 22 Jul 2009 11:08:29 +0000 Subject: [PATCH 050/352] Merge https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-vmiklos/ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11434 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 21 + Doc/Manual/Php.html | 386 +++++++++ Examples/php/callback/Makefile | 22 + Examples/php/callback/example.cxx | 4 + Examples/php/callback/example.h | 22 + Examples/php/callback/example.i | 13 + Examples/php/callback/index.html | 19 + Examples/php/callback/runme.php | 47 ++ Examples/php/extend/Makefile | 22 + Examples/php/extend/example.cxx | 4 + Examples/php/extend/example.h | 56 ++ Examples/php/extend/example.i | 15 + Examples/php/extend/index.html | 19 + Examples/php/extend/runme.php | 76 ++ Examples/python/callback/example.h | 1 - Examples/test-suite/director_detect.i | 2 + Examples/test-suite/director_protected.i | 7 + Examples/test-suite/director_stl.i | 4 + Examples/test-suite/li_factory.i | 3 + Examples/test-suite/php/Makefile.in | 2 +- .../php/director_abstract_runme.php | 62 ++ .../test-suite/php/director_basic_runme.php | 58 ++ .../test-suite/php/director_classic_runme.php | 150 ++++ .../test-suite/php/director_default_runme.php | 20 + .../test-suite/php/director_detect_runme.php | 55 ++ .../test-suite/php/director_enum_runme.php | 25 + .../php/director_exception_runme.php | 78 ++ .../test-suite/php/director_extend_runme.php | 29 + .../php/director_finalizer_runme.php | 61 ++ .../test-suite/php/director_frob_runme.php | 19 + .../test-suite/php/director_nested_runme.php | 75 ++ .../test-suite/php/director_profile_runme.php | 53 ++ .../php/director_protected_runme.php | 54 ++ .../test-suite/php/director_stl_runme.php | 60 ++ .../test-suite/php/director_string_runme.php | 34 + .../test-suite/php/director_thread_runme.php | 29 + .../test-suite/php/director_unroll_runme.php | 29 + .../php/evil_diamond_prop_runme.php | 3 +- Examples/test-suite/php/li_carrays_runme.php | 6 + Examples/test-suite/php/li_factory_runme.php | 22 + Examples/test-suite/php/newobject1_runme.php | 20 + Examples/test-suite/php/prefix_runme.php | 19 + Examples/test-suite/php/tests.php | 7 +- Examples/test-suite/prefix.i | 14 + Lib/php/director.swg | 198 +++++ Lib/php/factory.i | 109 +++ Lib/php/php.swg | 53 ++ Lib/php/phprun.swg | 30 +- Lib/php/std_string.i | 17 + Lib/php/utils.i | 4 + README | 1 + Source/Modules/overload.cxx | 6 +- Source/Modules/php.cxx | 759 ++++++++++++++++-- 53 files changed, 2838 insertions(+), 66 deletions(-) create mode 100644 Examples/php/callback/Makefile create mode 100644 Examples/php/callback/example.cxx create mode 100644 Examples/php/callback/example.h create mode 100644 Examples/php/callback/example.i create mode 100644 Examples/php/callback/index.html create mode 100644 Examples/php/callback/runme.php create mode 100644 Examples/php/extend/Makefile create mode 100644 Examples/php/extend/example.cxx create mode 100644 Examples/php/extend/example.h create mode 100644 Examples/php/extend/example.i create mode 100644 Examples/php/extend/index.html create mode 100644 Examples/php/extend/runme.php create mode 100644 Examples/test-suite/php/director_abstract_runme.php create mode 100644 Examples/test-suite/php/director_basic_runme.php create mode 100644 Examples/test-suite/php/director_classic_runme.php create mode 100644 Examples/test-suite/php/director_default_runme.php create mode 100644 Examples/test-suite/php/director_detect_runme.php create mode 100644 Examples/test-suite/php/director_enum_runme.php create mode 100644 Examples/test-suite/php/director_exception_runme.php create mode 100644 Examples/test-suite/php/director_extend_runme.php create mode 100644 Examples/test-suite/php/director_finalizer_runme.php create mode 100644 Examples/test-suite/php/director_frob_runme.php create mode 100644 Examples/test-suite/php/director_nested_runme.php create mode 100644 Examples/test-suite/php/director_profile_runme.php create mode 100644 Examples/test-suite/php/director_protected_runme.php create mode 100644 Examples/test-suite/php/director_stl_runme.php create mode 100644 Examples/test-suite/php/director_string_runme.php create mode 100644 Examples/test-suite/php/director_thread_runme.php create mode 100644 Examples/test-suite/php/director_unroll_runme.php create mode 100644 Examples/test-suite/php/li_factory_runme.php create mode 100644 Examples/test-suite/php/newobject1_runme.php create mode 100644 Examples/test-suite/php/prefix_runme.php create mode 100644 Examples/test-suite/prefix.i create mode 100644 Lib/php/director.swg create mode 100644 Lib/php/factory.i diff --git a/CHANGES.current b/CHANGES.current index 89057e97d..ece581863 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.40 (in progress) ============================ +2009-07-21: vmiklos + [PHP] Director support added. + 2009-07-15: olly [Perl] Don't specify Perl prototype "()" for a constructor with a different name to the class, as such constructors can still take @@ -17,6 +20,10 @@ Version 1.3.40 (in progress) of the manual. Based on patch from SF#2810380 by Christian Gollwitzer. +2009-07-02: vmiklos + [PHP] Added factory.i for PHP, see the li_factory testcase + for more info on how to use it. + 2009-07-02: wsfulton Fix -Wallkw option as reported by Solomon Gibbs. @@ -24,6 +31,14 @@ Version 1.3.40 (in progress) Fix syntax error when a nested struct contains a comment containing a * followed eventually by a /. Regression from 1.3.37, reported by Solomon Gibbs. +2009-07-01: vmiklos + [PHP] Unknown properties are no longer ignored in proxy + classes. + +2009-07-01: vmiklos + [PHP] Fixed %newobject behaviour, previously any method + marked with %newobject was handled as a constructor. + 2009-06-30: olly [Ruby] Undefine close and connect macros defined by Ruby API headers as we don't need them and they can clash with C++ methods @@ -66,6 +81,12 @@ Version 1.3.40 (in progress) *** POTENTIAL INCOMPATIBILITY *** +2009-05-20: vmiklos + [PHP] Add the 'thisown' member to classes. The usage of it + is the same as the Python thisown one: it's 1 by default and + you can set it to 0 if you want to prevent freeing it. (For + example to prevent a double free.) + 2009-05-14: bhy [Python] Fix the wrong pointer value returned by SwigPyObject_repr(). diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index ab2c73f6c..7bf158918 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -32,6 +32,16 @@

    7. PHP Pragmas, Startup and Shutdown code +
    8. Cross language polymorphism + @@ -866,5 +876,381 @@ The %rinit and %rshutdown statements insert code into the request init and shutdown code respectively.

      +

      29.3 Cross language polymorphism

      + + +

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

      + +

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

      + +

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

      + +

      29.3.1 Enabling directors

      + + +

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

      + +
      +
      +%module(directors="1") modulename
      +
      +
      + +

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

      + +
      +
      +// generate directors for all classes that have virtual methods
      +%feature("director");         
      +
      +// generate directors for all virtual methods in class Foo
      +%feature("director") Foo;      
      +
      +// generate a director for just Foo::bar()
      +%feature("director") Foo::bar; 
      +
      +
      + +

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

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

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

      + +

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

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

      +then at the PHP side you can define +

      + +
      +
      +require("mymodule.php");
      +
      +class MyFoo extends Foo {
      +  function one() {
      +     print "one from php\n";
      +  }
      +}
      +
      +
      + + +

      29.3.2 Director classes

      + + + + + +

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

      + +

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

      + +

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

      + +

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

      + +

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

      + +

      29.3.3 Ownership and object destruction

      + + +

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

      + +

      +This relationship can be reversed by calling the special +->thisown property of the proxy class. After setting this +property to 0, the director class no longer destroys the PHP +object. Assuming no outstanding references to the PHP object remain, +the PHP object will be destroyed at the same time. This is a good thing, +since directors and proxies refer to each other and so must be created +and destroyed together. Destroying one without destroying the other will +likely cause your program to segfault. +

      + +

      +Here is an example: +

      + +
      +
      +class Foo {
      +public:
      +    ...
      +};
      +class FooContainer {
      +public:
      +    void addFoo(Foo *);
      +    ...
      +};
      +
      +
      + +
      + +
      +
      +$c = new FooContainer();
      +$a = new Foo();
      +$a->thisown = 0;
      +$c->addFoo($a);
      +
      +
      + +

      +In this example, we are assuming that FooContainer will take care of +deleting all the Foo pointers it contains at some point. +

      + +

      29.3.4 Exception unrolling

      + + +

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

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

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

      + +

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

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

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

      + +

      29.3.5 Overhead and code bloat

      + + +

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

      + +

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

      + +

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

      + +

      29.3.6 Typemaps

      + + +

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

      + + +

      29.3.7 Miscellaneous

      + + +

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

      + diff --git a/Examples/php/callback/Makefile b/Examples/php/callback/Makefile new file mode 100644 index 000000000..42597202b --- /dev/null +++ b/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/Examples/php/callback/example.cxx b/Examples/php/callback/example.cxx new file mode 100644 index 000000000..450d75608 --- /dev/null +++ b/Examples/php/callback/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/php/callback/example.h b/Examples/php/callback/example.h new file mode 100644 index 000000000..2a0194999 --- /dev/null +++ b/Examples/php/callback/example.h @@ -0,0 +1,22 @@ +/* File : example.h */ + +#include + +class Callback { +public: + virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; } + virtual void run() { std::cout << "Callback::run()" << std::endl; } +}; + + +class Caller { +private: + Callback *_callback; +public: + Caller(): _callback(0) {} + ~Caller() { delCallback(); } + void delCallback() { delete _callback; _callback = 0; } + void setCallback(Callback *cb) { delCallback(); _callback = cb; } + void call() { if (_callback) _callback->run(); } +}; + diff --git a/Examples/php/callback/example.i b/Examples/php/callback/example.i new file mode 100644 index 000000000..90beda01a --- /dev/null +++ b/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/Examples/php/callback/index.html b/Examples/php/callback/index.html new file mode 100644 index 000000000..2aa720e24 --- /dev/null +++ b/Examples/php/callback/index.html @@ -0,0 +1,19 @@ + + +SWIG:Examples:php:callback + + + + + +SWIG/Examples/php/callback/ +
      + +

      Implementing C++ callbacks in PHP

      + +

      +This example illustrates how to use directors to implement C++ callbacks in PHP. + +


      + + diff --git a/Examples/php/callback/runme.php b/Examples/php/callback/runme.php new file mode 100644 index 000000000..2be71994f --- /dev/null +++ b/Examples/php/callback/runme.php @@ -0,0 +1,47 @@ +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/Examples/php/extend/Makefile b/Examples/php/extend/Makefile new file mode 100644 index 000000000..42597202b --- /dev/null +++ b/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/Examples/php/extend/example.cxx b/Examples/php/extend/example.cxx new file mode 100644 index 000000000..450d75608 --- /dev/null +++ b/Examples/php/extend/example.cxx @@ -0,0 +1,4 @@ +/* File : example.cxx */ + +#include "example.h" + diff --git a/Examples/php/extend/example.h b/Examples/php/extend/example.h new file mode 100644 index 000000000..b27ab9711 --- /dev/null +++ b/Examples/php/extend/example.h @@ -0,0 +1,56 @@ +/* File : example.h */ + +#include +#include +#include +#include +#include + +class Employee { +private: + std::string name; +public: + Employee(const char* n): name(n) {} + virtual std::string getTitle() { return getPosition() + " " + getName(); } + virtual std::string getName() { return name; } + virtual std::string getPosition() const { return "Employee"; } + virtual ~Employee() { printf("~Employee() @ %p\n", this); } +}; + + +class Manager: public Employee { +public: + Manager(const char* n): Employee(n) {} + virtual std::string getPosition() const { return "Manager"; } +}; + + +class EmployeeList { + std::vector list; +public: + EmployeeList() { + list.push_back(new Employee("Bob")); + list.push_back(new Employee("Jane")); + list.push_back(new Manager("Ted")); + } + void addEmployee(Employee *p) { + list.push_back(p); + std::cout << "New employee added. Current employees are:" << std::endl; + std::vector::iterator i; + for (i=list.begin(); i!=list.end(); i++) { + std::cout << " " << (*i)->getTitle() << std::endl; + } + } + const Employee *get_item(int i) { + return list[i]; + } + ~EmployeeList() { + std::vector::iterator i; + std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl; + for (i=list.begin(); i!=list.end(); i++) { + delete *i; + } + std::cout << "~EmployeeList empty." << std::endl; + } +}; + diff --git a/Examples/php/extend/example.i b/Examples/php/extend/example.i new file mode 100644 index 000000000..c8ec32e09 --- /dev/null +++ b/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/Examples/php/extend/index.html b/Examples/php/extend/index.html new file mode 100644 index 000000000..32c6a4913 --- /dev/null +++ b/Examples/php/extend/index.html @@ -0,0 +1,19 @@ + + +SWIG:Examples:php:extend + + + + + +SWIG/Examples/php/extend/ +
      + +

      Extending a simple C++ class in PHP

      + +

      +This example illustrates the extending of a C++ class with cross language polymorphism. + +


      + + diff --git a/Examples/php/extend/runme.php b/Examples/php/extend/runme.php new file mode 100644 index 000000000..158683142 --- /dev/null +++ b/Examples/php/extend/runme.php @@ -0,0 +1,76 @@ +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/Examples/python/callback/example.h b/Examples/python/callback/example.h index 1a0e8c432..2a0194999 100644 --- a/Examples/python/callback/example.h +++ b/Examples/python/callback/example.h @@ -1,6 +1,5 @@ /* File : example.h */ -#include #include class Callback { diff --git a/Examples/test-suite/director_detect.i b/Examples/test-suite/director_detect.i index 355e5ee91..fcb01b3e9 100644 --- a/Examples/test-suite/director_detect.i +++ b/Examples/test-suite/director_detect.i @@ -15,7 +15,9 @@ %feature("director") Foo; %newobject Foo::cloner(); +%newobject Foo::get_class(); %newobject Bar::cloner(); +%newobject Bar::get_class(); %inline { diff --git a/Examples/test-suite/director_protected.i b/Examples/test-suite/director_protected.i index df3418506..fee45b4a6 100644 --- a/Examples/test-suite/director_protected.i +++ b/Examples/test-suite/director_protected.i @@ -11,6 +11,13 @@ %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; diff --git a/Examples/test-suite/director_stl.i b/Examples/test-suite/director_stl.i index cbcb4ba85..46946e513 100644 --- a/Examples/test-suite/director_stl.i +++ b/Examples/test-suite/director_stl.i @@ -17,7 +17,11 @@ %feature("director") Foo; %feature("director:except") { +#ifndef SWIGPHP if ($error != NULL) { +#else + if ($error == FAILURE) { +#endif throw Swig::DirectorMethodException(); } } diff --git a/Examples/test-suite/li_factory.i b/Examples/test-suite/li_factory.i index dcd8b308a..7c59d53b2 100644 --- a/Examples/test-suite/li_factory.i +++ b/Examples/test-suite/li_factory.i @@ -6,6 +6,9 @@ %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); diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index 021417fd2..679b46b54 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -17,7 +17,7 @@ include $(srcdir)/../common.mk TARGETPREFIX =# Should be php_ for Windows, empty otherwise # Custom tests - tests with additional commandline options -# none! +prefix.cpptest: SWIGOPT += -prefix Project # write out tests without a _runme.php missingcpptests: diff --git a/Examples/test-suite/php/director_abstract_runme.php b/Examples/test-suite/php/director_abstract_runme.php new file mode 100644 index 000000000..ca3d676da --- /dev/null +++ b/Examples/test-suite/php/director_abstract_runme.php @@ -0,0 +1,62 @@ +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/Examples/test-suite/php/director_basic_runme.php b/Examples/test-suite/php/director_basic_runme.php new file mode 100644 index 000000000..de6b50502 --- /dev/null +++ b/Examples/test-suite/php/director_basic_runme.php @@ -0,0 +1,58 @@ +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/Examples/test-suite/php/director_classic_runme.php b/Examples/test-suite/php/director_classic_runme.php new file mode 100644 index 000000000..d2da1b1ba --- /dev/null +++ b/Examples/test-suite/php/director_classic_runme.php @@ -0,0 +1,150 @@ +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/Examples/test-suite/php/director_default_runme.php b/Examples/test-suite/php/director_default_runme.php new file mode 100644 index 000000000..f97fc7425 --- /dev/null +++ b/Examples/test-suite/php/director_default_runme.php @@ -0,0 +1,20 @@ + diff --git a/Examples/test-suite/php/director_detect_runme.php b/Examples/test-suite/php/director_detect_runme.php new file mode 100644 index 000000000..cc19c0302 --- /dev/null +++ b/Examples/test-suite/php/director_detect_runme.php @@ -0,0 +1,55 @@ +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/Examples/test-suite/php/director_enum_runme.php b/Examples/test-suite/php/director_enum_runme.php new file mode 100644 index 000000000..8f6487a28 --- /dev/null +++ b/Examples/test-suite/php/director_enum_runme.php @@ -0,0 +1,25 @@ +say_hi(director_enum::hello), $b->say_hello(director_enum::hi), "say failed"); + +check::done(); +?> diff --git a/Examples/test-suite/php/director_exception_runme.php b/Examples/test-suite/php/director_exception_runme.php new file mode 100644 index 000000000..33e6e9b52 --- /dev/null +++ b/Examples/test-suite/php/director_exception_runme.php @@ -0,0 +1,78 @@ +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/Examples/test-suite/php/director_extend_runme.php b/Examples/test-suite/php/director_extend_runme.php new file mode 100644 index 000000000..f282df17d --- /dev/null +++ b/Examples/test-suite/php/director_extend_runme.php @@ -0,0 +1,29 @@ +dummy(), 666, "1st call"); +check::equal($m->dummy(), 666, "2st call"); // Locked system + +check::done(); +?> diff --git a/Examples/test-suite/php/director_finalizer_runme.php b/Examples/test-suite/php/director_finalizer_runme.php new file mode 100644 index 000000000..0fcddfd8b --- /dev/null +++ b/Examples/test-suite/php/director_finalizer_runme.php @@ -0,0 +1,61 @@ +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/Examples/test-suite/php/director_frob_runme.php b/Examples/test-suite/php/director_frob_runme.php new file mode 100644 index 000000000..548b0b804 --- /dev/null +++ b/Examples/test-suite/php/director_frob_runme.php @@ -0,0 +1,19 @@ +abs_method(); + +check::equal($s, "Bravo::abs_method()", "s failed"); + +check::done(); +?> diff --git a/Examples/test-suite/php/director_nested_runme.php b/Examples/test-suite/php/director_nested_runme.php new file mode 100644 index 000000000..b4d345886 --- /dev/null +++ b/Examples/test-suite/php/director_nested_runme.php @@ -0,0 +1,75 @@ +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/Examples/test-suite/php/director_profile_runme.php b/Examples/test-suite/php/director_profile_runme.php new file mode 100644 index 000000000..c72421341 --- /dev/null +++ b/Examples/test-suite/php/director_profile_runme.php @@ -0,0 +1,53 @@ +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/Examples/test-suite/php/director_protected_runme.php b/Examples/test-suite/php/director_protected_runme.php new file mode 100644 index 000000000..73bcba1fd --- /dev/null +++ b/Examples/test-suite/php/director_protected_runme.php @@ -0,0 +1,54 @@ +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/Examples/test-suite/php/director_stl_runme.php b/Examples/test-suite/php/director_stl_runme.php new file mode 100644 index 000000000..29addd261 --- /dev/null +++ b/Examples/test-suite/php/director_stl_runme.php @@ -0,0 +1,60 @@ +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/Examples/test-suite/php/director_string_runme.php b/Examples/test-suite/php/director_string_runme.php new file mode 100644 index 000000000..b239e47fb --- /dev/null +++ b/Examples/test-suite/php/director_string_runme.php @@ -0,0 +1,34 @@ +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/Examples/test-suite/php/director_thread_runme.php b/Examples/test-suite/php/director_thread_runme.php new file mode 100644 index 000000000..8df25d969 --- /dev/null +++ b/Examples/test-suite/php/director_thread_runme.php @@ -0,0 +1,29 @@ +val = $this->val - 1; + } +} + +$d = new Derived(); +$d->run(); + +if ($d->val >= 0) { + check::fail($d->val); +} + +$d->stop(); + +check::done(); +?> diff --git a/Examples/test-suite/php/director_unroll_runme.php b/Examples/test-suite/php/director_unroll_runme.php new file mode 100644 index 000000000..626b1f07d --- /dev/null +++ b/Examples/test-suite/php/director_unroll_runme.php @@ -0,0 +1,29 @@ +set($a); +$c = $b->get(); + +check::equal($a->this, $c->this, "this failed"); + +check::done(); +?> diff --git a/Examples/test-suite/php/evil_diamond_prop_runme.php b/Examples/test-suite/php/evil_diamond_prop_runme.php index 6f66d01c5..6cf984d8e 100644 --- a/Examples/test-suite/php/evil_diamond_prop_runme.php +++ b/Examples/test-suite/php/evil_diamond_prop_runme.php @@ -31,7 +31,8 @@ $spam=new spam(); check::is_a($spam,"spam"); check::equal(1,$spam->_foo,"1==spam->_foo"); check::equal(2,$spam->_bar,"2==spam->_bar"); -check::equal(3,$spam->_baz,"3==spam->_baz"); +// 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/Examples/test-suite/php/li_carrays_runme.php b/Examples/test-suite/php/li_carrays_runme.php index babf8443b..8972b9fc2 100644 --- a/Examples/test-suite/php/li_carrays_runme.php +++ b/Examples/test-suite/php/li_carrays_runme.php @@ -11,5 +11,11 @@ check::classes(array(doubleArray)); // now new vars check::globals(array()); +$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/Examples/test-suite/php/li_factory_runme.php b/Examples/test-suite/php/li_factory_runme.php new file mode 100644 index 000000000..6623e2a8c --- /dev/null +++ b/Examples/test-suite/php/li_factory_runme.php @@ -0,0 +1,22 @@ +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/Examples/test-suite/php/newobject1_runme.php b/Examples/test-suite/php/newobject1_runme.php new file mode 100644 index 000000000..b105ad755 --- /dev/null +++ b/Examples/test-suite/php/newobject1_runme.php @@ -0,0 +1,20 @@ +makeMore(); +check::equal(get_class($bar), "Foo", "regular failed"); + +check::done(); +?> diff --git a/Examples/test-suite/php/prefix_runme.php b/Examples/test-suite/php/prefix_runme.php new file mode 100644 index 000000000..6adc1375e --- /dev/null +++ b/Examples/test-suite/php/prefix_runme.php @@ -0,0 +1,19 @@ +get_self(); + +check::done(); +?> diff --git a/Examples/test-suite/php/tests.php b/Examples/test-suite/php/tests.php index b62e878fc..ad58ac9d8 100644 --- a/Examples/test-suite/php/tests.php +++ b/Examples/test-suite/php/tests.php @@ -34,8 +34,11 @@ class check { $df=array_flip($df[internal]); foreach($_original_functions[internal] as $func) unset($df[$func]); // Now chop out any get/set accessors - foreach(array_keys($df) as $func) if (GETSET && ereg('_[gs]et$',$func)) $extrags[]=$func; - else $extra[]=$func; + 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; diff --git a/Examples/test-suite/prefix.i b/Examples/test-suite/prefix.i new file mode 100644 index 000000000..b0cb31205 --- /dev/null +++ b/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/Lib/php/director.swg b/Lib/php/director.swg new file mode 100644 index 000000000..6a9d4df3c --- /dev/null +++ b/Lib/php/director.swg @@ -0,0 +1,198 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * director.swg + * + * This file contains support for director classes that proxy + * method calls from C++ to PHP extensions. + * ----------------------------------------------------------------------------- */ + +#ifndef SWIG_DIRECTOR_PHP_HEADER_ +#define SWIG_DIRECTOR_PHP_HEADER_ + +#ifdef __cplusplus + +#include +#include + +/* + Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the + 'Swig' namespace. This could be useful for multi-modules projects. +*/ +#ifdef SWIG_DIRECTOR_STATIC +/* Force anonymous (static) namespace */ +#define Swig +#endif + +namespace Swig { + /* memory handler */ + struct GCItem + { + virtual ~GCItem() {} + + virtual int get_own() const + { + return 0; + } + }; + + struct GCItem_var + { + GCItem_var(GCItem *item = 0) : _item(item) + { + } + + GCItem_var& operator=(GCItem *item) + { + GCItem *tmp = _item; + _item = item; + delete tmp; + return *this; + } + + ~GCItem_var() + { + delete _item; + } + + GCItem * operator->() const + { + return _item; + } + + private: + GCItem *_item; + }; + + struct GCItem_Object : GCItem + { + GCItem_Object(int own) : _own(own) + { + } + + virtual ~GCItem_Object() + { + } + + int get_own() const + { + return _own; + } + + private: + int _own; + }; + + template + struct GCItem_T : GCItem + { + GCItem_T(Type *ptr) : _ptr(ptr) + { + } + + virtual ~GCItem_T() + { + delete _ptr; + } + + private: + Type *_ptr; + }; + + class Director { + protected: + zval *swig_self; + typedef std::map ownership_map; + mutable ownership_map owner; + public: + Director(zval* self) : swig_self(self) { + } + + ~Director() { + for (ownership_map::iterator i = owner.begin(); i != owner.end(); i++) { + owner.erase(i); + } + } + + bool is_overriden_method(char *cname, char *lc_fname) { + zval classname; + zend_class_entry **ce; + zend_function *mptr; + int name_len = strlen(lc_fname); + + ZVAL_STRING(&classname, cname, 0); + if (zend_lookup_class(Z_STRVAL_P(&classname), Z_STRLEN_P(&classname), &ce TSRMLS_CC) != SUCCESS) { + return false; + } + if (zend_hash_find(&(*ce)->function_table, lc_fname, name_len + 1, (void**) &mptr) != SUCCESS) { + return false; + } + // common.scope points to the declaring class + return strcmp(mptr->common.scope->name, cname); + } + + template + void swig_acquire_ownership(Type *vptr) const + { + if (vptr) { + owner[vptr] = new GCItem_T(vptr); + } + } + }; + + /* base class for director exceptions */ + class DirectorException { + protected: + std::string swig_msg; + public: + DirectorException(int code, const char *hdr, const char* msg) + : swig_msg(hdr) + { + if (strlen(msg)) { + swig_msg += " "; + swig_msg += msg; + } + SWIG_ErrorCode() = code; + SWIG_ErrorMsg() = swig_msg.c_str(); + } + + static void raise(int code, const char *hdr, const char* msg) + { + throw DirectorException(code, hdr, msg); + } + }; + + /* attempt to call a pure virtual method via a director method */ + class DirectorPureVirtualException : public Swig::DirectorException + { + public: + DirectorPureVirtualException(const char* msg) + : DirectorException(E_ERROR, "Swig director pure virtual method called", msg) + { + } + + static void raise(const char *msg) + { + throw DirectorPureVirtualException(msg); + } + }; + /* any php exception that occurs during a director method call */ + class DirectorMethodException : public Swig::DirectorException + { + public: + DirectorMethodException(const char* msg = "") + : DirectorException(E_ERROR, "Swig director method error", msg) + { + } + + static void raise(const char *msg) + { + throw DirectorMethodException(msg); + } + }; +} + +#endif /* __cplusplus */ + +#endif diff --git a/Lib/php/factory.i b/Lib/php/factory.i new file mode 100644 index 000000000..c4e082dd2 --- /dev/null +++ b/Lib/php/factory.i @@ -0,0 +1,109 @@ +/* + Implement a more natural wrap for factory methods, for example, if + you have: + + ---- geometry.h -------- + struct Geometry { + enum GeomType{ + POINT, + CIRCLE + }; + + virtual ~Geometry() {} + virtual int draw() = 0; + + // + // Factory method for all the Geometry objects + // + static Geometry *create(GeomType i); + }; + + struct Point : Geometry { + int draw() { return 1; } + double width() { return 1.0; } + }; + + struct Circle : Geometry { + int draw() { return 2; } + double radius() { return 1.5; } + }; + + // + // Factory method for all the Geometry objects + // + Geometry *Geometry::create(GeomType type) { + switch (type) { + case POINT: return new Point(); + case CIRCLE: return new Circle(); + default: return 0; + } + } + ---- geometry.h -------- + + + You can use the %factory with the Geometry::create method as follows: + + %newobject Geometry::create; + %factory(Geometry *Geometry::create, Point, Circle); + %include "geometry.h" + + and Geometry::create will return a 'Point' or 'Circle' instance + instead of the plain 'Geometry' type. For example, in python: + + circle = Geometry.create(Geometry.CIRCLE) + r = circle.radius() + + where circle is a Circle proxy instance. + + NOTES: remember to fully qualify all the type names and don't + use %factory inside a namespace declaration, ie, instead of + + namespace Foo { + %factory(Geometry *Geometry::create, Point, Circle); + } + + use + + %factory(Foo::Geometry *Foo::Geometry::create, Foo::Point, Foo::Circle); + + +*/ + +/* for loop for macro with one argument */ +%define %_formacro_1(macro, arg1,...)macro(arg1) +#if #__VA_ARGS__ != "__fordone__" +%_formacro_1(macro, __VA_ARGS__) +#endif +%enddef + +/* for loop for macro with one argument */ +%define %formacro_1(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef +%define %formacro(macro,...)%_formacro_1(macro,__VA_ARGS__,__fordone__)%enddef + +/* for loop for macro with two arguments */ +%define %_formacro_2(macro, arg1, arg2, ...)macro(arg1, arg2) +#if #__VA_ARGS__ != "__fordone__" +%_formacro_2(macro, __VA_ARGS__) +#endif +%enddef + +/* for loop for macro with two arguments */ +%define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef + +%define %_factory_dispatch(Type) +if (!dcast) { + Type *dobj = dynamic_cast($1); + if (dobj) { + dcast = 1; + SWIG_SetPointerZval(return_value, SWIG_as_voidptr(dobj),$descriptor(Type *), $owner); + } +}%enddef + +%define %factory(Method,Types...) +%typemap(out) Method { + int dcast = 0; + %formacro(%_factory_dispatch, Types) + if (!dcast) { + SWIG_SetPointerZval(return_value, SWIG_as_voidptr($1),$descriptor, $owner); + } +}%enddef diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 087525be4..42cb8db4a 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -89,6 +89,14 @@ $1 = *tmp; } +%typemap(directorout) SWIGTYPE ($&1_ltype tmp) +{ + if(SWIG_ConvertPtr(*$input, (void **) &tmp, $&1_descriptor, 0) < 0 || tmp == NULL) { + SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); + } + $result = *tmp; +} + %typemap(in) SWIGTYPE *, SWIGTYPE [] { @@ -176,17 +184,42 @@ ZVAL_LONG(return_value,$1); } +%typemap(directorin) int, + unsigned int, + short, + unsigned short, + long, + unsigned long, + signed char, + unsigned char, + size_t, + enum SWIGTYPE +{ + ZVAL_LONG($input,$1_name); +} + %typemap(out) bool { ZVAL_BOOL(return_value,($1)?1:0); } +%typemap(directorin) bool +{ + ZVAL_BOOL($input,($1_name)?1:0); +} + %typemap(out) float, double { ZVAL_DOUBLE(return_value,$1); } +%typemap(directorin) float, + double +{ + ZVAL_DOUBLE($input,$1_name); +} + %typemap(out) char { ZVAL_STRINGL(return_value,&$1, 1, 1); @@ -209,6 +242,13 @@ SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); %} +%typemap(directorin) SWIGTYPE *, + SWIGTYPE [], + SWIGTYPE & +%{ + SWIG_SetPointerZval($input, (void *)&$1_name, $1_descriptor, $owner); +%} + %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { @@ -230,6 +270,19 @@ } #endif +%typemap(directorin) SWIGTYPE +#ifdef __cplusplus +{ + SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1_name), $&1_descriptor, 2); +} +#else +{ + $&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type)); + memcpy(resultobj, &$1, sizeof($1_type)); + SWIG_SetPointerZval($input, (void *)resultobj, $&1_descriptor, 2); +} +#endif + %typemap(out) void ""; %typemap(out) char [ANY] diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index 131c5ba3a..992745323 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -13,6 +13,7 @@ extern "C" { #include "zend.h" #include "zend_API.h" #include "php.h" +#include "ext/standard/php_string.h" #ifdef ZEND_RAW_FENTRY /* ZEND_RAW_FENTRY was added somewhere between 5.2.0 and 5.2.3 */ @@ -84,6 +85,7 @@ typedef struct { static ZEND_RSRC_DTOR_FUNC(SWIG_landfill) { (void)rsrc; } #define SWIG_SetPointerZval(a,b,c,d) SWIG_ZTS_SetPointerZval(a,b,c,d TSRMLS_CC) +#define SWIG_as_voidptr(a) const_cast< void * >(static_cast< const void * >(a)) static void SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject TSRMLS_DC) { @@ -101,7 +103,31 @@ SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper)); value->ptr=ptr; value->newobject=newobject; - ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); + if (newobject <= 1) { + ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); + } else { + value->newobject = 0; + zval *resource; + MAKE_STD_ZVAL(resource); + ZEND_REGISTER_RESOURCE(resource, value, *(int *)(type->clientdata)); + zend_class_entry **ce = NULL; + zval *classname; + MAKE_STD_ZVAL(classname); + /* _p_Foo -> Foo */ + ZVAL_STRING(classname, (char*)type->name+3, 1); + /* class names are stored in lowercase */ + php_strtolower(Z_STRVAL_PP(&classname), Z_STRLEN_PP(&classname)); + if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &ce TSRMLS_CC) != SUCCESS) { + /* class does not exists */ + object_init(z); + } else { + object_init_ex(z, *ce); + } + z->refcount = 1; + z->is_ref = 1; + zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval), NULL); + FREE_ZVAL(classname); + } return; } zend_error(E_ERROR, "Type: %s not registered with zend",type->name); @@ -156,7 +182,7 @@ SWIG_ZTS_ConvertResourcePtr(zval *z, swig_type_info *ty, int flags TSRMLS_DC) { char *type_name; value = (swig_object_wrapper *) zend_list_find(z->value.lval, &type); - if ( flags && SWIG_POINTER_DISOWN ) { + if ( flags & SWIG_POINTER_DISOWN ) { value->newobject = 0; } p = value->ptr; diff --git a/Lib/php/std_string.i b/Lib/php/std_string.i index 08a7cdac9..eff6951b5 100644 --- a/Lib/php/std_string.i +++ b/Lib/php/std_string.i @@ -35,6 +35,11 @@ namespace std { $1.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); %} + %typemap(directorout) string %{ + convert_to_string_ex($input); + $result.assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); + %} + %typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) const string& %{ $1 = ( Z_TYPE_PP($input) == IS_STRING ) ? 1 : 0; %} @@ -43,6 +48,10 @@ namespace std { ZVAL_STRINGL($result, const_cast($1.data()), $1.size(), 1); %} + %typemap(directorin) string %{ + ZVAL_STRINGL($input, const_cast($1_name.data()), $1_name.size(), 1); + %} + %typemap(out) const string & %{ ZVAL_STRINGL($result, const_cast($1->data()), $1->size(), 1); %} @@ -63,6 +72,14 @@ namespace std { $1 = &temp; %} + %typemap(directorout) string & (std::string *temp) %{ + convert_to_string_ex($input); + temp = new std::string; + temp->assign(Z_STRVAL_PP($input), Z_STRLEN_PP($input)); + swig_acquire_ownership(temp); + $result = temp; + %} + %typemap(argout) string & %{ ZVAL_STRINGL(*($input), const_cast($1->data()), $1->size(), 1); %} diff --git a/Lib/php/utils.i b/Lib/php/utils.i index facf54196..becaf598a 100644 --- a/Lib/php/utils.i +++ b/Lib/php/utils.i @@ -37,6 +37,10 @@ %{ CONVERT_IN($1,$1_ltype,$input); %} +%typemap(directorout) TYPE, const TYPE & +%{ + CONVERT_IN($result,$1_ltype,$input); +%} %enddef %fragment("t_output_helper","header") %{ diff --git a/README b/README index 179b3ff56..5fde83996 100644 --- a/README +++ b/README @@ -59,6 +59,7 @@ Major contributors include: Martin Froehlich (Guile) Marcio Luis Teixeira (Guile) Duncan Temple Lang (R) + Miklos Vajna (PHP directors) Past contributors include: James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 511e55004..79656517a 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -718,6 +718,10 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar Parm *pi = Getattr(ni, "wrap:parms"); int num_required = emit_num_required(pi); int num_arguments = emit_num_arguments(pi); + if (GetFlag(n, "wrap:this")) { + num_required++; + num_arguments++; + } if (num_arguments > *maxargs) *maxargs = num_arguments; int varargs = emit_isvarargs(pi); @@ -751,7 +755,7 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar Printf(f, "}\n"); Delete(lfmt); } - if (print_typecheck(f, j, pj)) { + if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj)) { Printf(f, "if (_v) {\n"); num_braces++; } diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index e3b22f1d3..8d65df889 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -62,6 +62,11 @@ PHP Options (available with -php)\n\ */ #define SWIG_PTR "_cPtr" +/* This is the name of the hash where the variables existing only in PHP + * classes are stored. + */ +#define SWIG_DATA "_pData" + static int constructors = 0; static String *NOTCLASS = NewString("Not a class"); static Node *classnode = 0; @@ -73,8 +78,11 @@ static String *shadow_classname = 0; static File *f_begin = 0; static File *f_runtime = 0; +static File *f_runtime_h = 0; static File *f_h = 0; static File *f_phpcode = 0; +static File *f_directors = 0; +static File *f_directors_h = 0; static String *phpfilename = 0; static String *s_header; @@ -117,6 +125,7 @@ static enum { membervar, staticmembervar, constructor, + directorconstructor, destructor } wrapperType = standard; @@ -175,7 +184,9 @@ void SwigPHP_emit_resource_registrations() { class PHP : public Language { public: - PHP() { } + PHP() { + director_language = 1; + } /* Test to see if a type corresponds to something wrapped with a shadow class. */ @@ -256,8 +267,21 @@ public: String *filen; String *s_type; + /* Check if directors are enabled for this module. */ + Node *mod = Getattr(n, "module"); + if (mod) { + Node *options = Getattr(mod, "options"); + if (options && Getattr(options, "directors")) { + allow_directors(); + } + } + + /* Set comparison with null for ConstructorToFunction */ + setSubclassInstanceCheck(NewString("$arg->type != IS_NULL")); + /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); + String *outfile_h = Getattr(n, "outfile_h"); /* main output file */ f_begin = NewFile(outfile, "w", SWIG_output_files()); @@ -265,7 +289,7 @@ public: FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); + f_runtime = NewStringEmpty(); /* sections of the output file */ s_init = NewString("/* init section */\n"); @@ -282,6 +306,16 @@ public: s_oinit = NewString("/* oinit subsection */\n"); pragma_phpinfo = NewStringEmpty(); s_phpclasses = NewString("/* PHP Proxy Classes */\n"); + f_directors_h = NewStringEmpty(); + f_directors = NewStringEmpty(); + + if (directorsEnabled()) { + f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); + if (!f_runtime_h) { + FileErrorDisplay(outfile_h); + SWIG_exit(EXIT_FAILURE); + } + } /* Register file targets with the SWIG file handler */ Swig_register_filebyname("begin", f_begin); @@ -292,6 +326,8 @@ public: Swig_register_filebyname("rshutdown", r_shutdown); Swig_register_filebyname("header", s_header); Swig_register_filebyname("wrapper", s_wrappers); + Swig_register_filebyname("director", f_directors); + Swig_register_filebyname("director_h", f_directors_h); Swig_banner(f_begin); @@ -299,12 +335,25 @@ public: Printf(f_runtime, "#define SWIGPHP\n"); Printf(f_runtime, "\n"); + if (directorsEnabled()) { + Printf(f_runtime, "#define SWIG_DIRECTORS\n"); + } + /* Set the module name */ module = Copy(Getattr(n, "name")); cap_module = NewStringf("%(upper)s", module); if (!prefix) prefix = NewStringEmpty(); + if (directorsEnabled()) { + Swig_banner(f_directors_h); + Printf(f_directors_h, "\n"); + Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", cap_module); + Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", cap_module); + + Printf(f_directors, "\n#include \"%s\"\n\n", Swig_file_filename(outfile_h)); + } + /* PHP module file */ filen = NewStringEmpty(); Printv(filen, SWIG_output_directory(), module, ".php", NIL); @@ -371,6 +420,39 @@ public: Printf(s_header, " SWIG_ErrorCode() = default_error_code;\n"); Printf(s_header, "}\n"); + Append(s_header, "\n"); + Printf(s_header, "ZEND_NAMED_FUNCTION(_wrap_swig_%s_alter_newobject) {\n", module); + Append(s_header, " zval **args[2];\n"); + Append(s_header, " swig_object_wrapper *value;\n"); + Append(s_header, " int type;\n"); + Append(s_header, " int thisown;\n"); + Append(s_header, "\n"); + Append(s_header, " SWIG_ResetError();\n"); + Append(s_header, " if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) {\n"); + Append(s_header, " WRONG_PARAM_COUNT;\n"); + Append(s_header, " }\n"); + Append(s_header, "\n"); + Append(s_header, " value = (swig_object_wrapper *) zend_list_find((*args[0])->value.lval, &type);\n"); + Append(s_header, " value->newobject = zval_is_true(*args[1]);\n"); + Append(s_header, "\n"); + Append(s_header, " return;\n"); + Append(s_header, "}\n"); + Printf(s_header, "ZEND_NAMED_FUNCTION(_wrap_swig_%s_get_newobject) {\n", module); + Append(s_header, " zval **args[1];\n"); + Append(s_header, " swig_object_wrapper *value;\n"); + Append(s_header, " int type;\n"); + Append(s_header, "\n"); + Append(s_header, " SWIG_ResetError();\n"); + Append(s_header, " if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {\n"); + Append(s_header, " WRONG_PARAM_COUNT;\n"); + Append(s_header, " }\n"); + Append(s_header, "\n"); + Append(s_header, " value = (swig_object_wrapper *) zend_list_find((*args[0])->value.lval, &type);\n"); + Append(s_header, " RETVAL_LONG(value->newobject);\n"); + Append(s_header, "\n"); + Append(s_header, " return;\n"); + Append(s_header, "}\n"); + Printf(s_header, "#define SWIG_name \"%s\"\n", module); /* Printf(s_header,"#ifdef HAVE_CONFIG_H\n"); Printf(s_header,"#include \"config.h\"\n"); @@ -387,6 +469,11 @@ public: Printf(s_header, "}\n"); Printf(s_header, "#endif\n\n"); + if (directorsEnabled()) { + // Insert director runtime + Swig_insert_file("director.swg", s_header); + } + /* Create the .h file too */ filen = NewStringEmpty(); Printv(filen, SWIG_output_directory(), "php_", module, ".h", NIL); @@ -523,13 +610,27 @@ public: * function really needs totally redoing. */ + if (directorsEnabled()) { + Dump(f_directors_h, f_runtime_h); + Printf(f_runtime_h, "\n"); + Printf(f_runtime_h, "#endif\n"); + Close(f_runtime_h); + } + Printf(s_header, "/* end header section */\n"); Printf(s_wrappers, "/* end wrapper section */\n"); Printf(s_vdecl, "/* end vdecl subsection */\n"); Dump(f_runtime, f_begin); - Printv(f_begin, s_header, s_vdecl, s_wrappers, NIL); - Printv(f_begin, all_cs_entry, "\n\n", s_entry, "{NULL, NULL, NULL}\n};\n\n", NIL); + Printv(f_begin, s_header, NIL); + if (directorsEnabled()) { + Dump(f_directors, f_begin); + } + Printv(f_begin, s_vdecl, s_wrappers, NIL); + Printv(f_begin, all_cs_entry, "\n\n", s_entry, + " SWIG_ZEND_NAMED_FE(swig_", module, "_alter_newobject,_wrap_swig_", module, "_alter_newobject,NULL)\n" + " SWIG_ZEND_NAMED_FE(swig_", module, "_get_newobject,_wrap_swig_", module, "_get_newobject,NULL)\n" + "{NULL, NULL, NULL}\n};\n\n", NIL); Printv(f_begin, s_init, NIL); Delete(s_header); Delete(s_wrappers); @@ -572,6 +673,10 @@ public: int maxargs; String *tmp = NewStringEmpty(); + if (Swig_directorclass(n) && wrapperType == directorconstructor) { + /* We have an extra 'this' parameter. */ + SetFlag(n, "wrap:this"); + } String *dispatch = Swig_overload_dispatch(n, "return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);", &maxargs); /* Generate a dispatch wrapper for all overloaded functions */ @@ -633,6 +738,7 @@ public: ParmList *l = Getattr(n, "parms"); String *nodeType = Getattr(n, "nodeType"); int newobject = GetFlag(n, "feature:new"); + int constructor = (Cmp(nodeType, "constructor") == 0); Parm *p; int i; @@ -688,12 +794,26 @@ public: int num_required = emit_num_required(l); numopt = num_arguments - num_required; + if (wrapperType == directorconstructor) + num_arguments++; + if (num_arguments > 0) { - String *args = NewStringf("zval **args[%d]", num_arguments); + String *args = NewStringEmpty(); + if (wrapperType == directorconstructor) + Wrapper_add_local(f, "arg0", "zval *arg0"); + Printf(args, "zval **args[%d]", num_arguments); Wrapper_add_local(f, "args", args); Delete(args); args = NULL; } + if (is_member_director(n)) { + Wrapper_add_local(f, "director", "Swig::Director *director = 0"); + Printf(f->code, "director = dynamic_cast(arg1);\n"); + Wrapper_add_local(f, "upcall", "bool upcall = false"); + Printf(f->code, "upcall = !director->is_overriden_method((char *)\"%s\", (char *)\"%s\");\n", + Swig_class_name(Swig_methodclass(n)), name); + } + // This generated code may be called: // 1) as an object method, or // 2) as a class-method/function (without a "this_ptr") @@ -718,6 +838,8 @@ public: } Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n"); } + if (wrapperType == directorconstructor) + Printf(f->code, "arg0 = *args[0];\n \n"); /* Now convert from PHP to C variables */ // At this point, argcount if used is the number of deliberately passed args @@ -729,7 +851,10 @@ public: // _this and not the first argument. // This may mean looking at Language::memberfunctionHandler - for (i = 0, p = l; i < num_arguments; i++) { + int limit = num_arguments; + if (wrapperType == directorconstructor) + limit--; + for (i = 0, p = l; i < limit; i++) { String *source; /* Skip ignored arguments */ @@ -740,7 +865,11 @@ public: SwigType *pt = Getattr(p, "type"); - source = NewStringf("args[%d]", i); + if (wrapperType == directorconstructor) { + source = NewStringf("args[%d]", i+1); + } else { + source = NewStringf("args[%d]", i); + } String *ln = Getattr(p, "lname"); @@ -772,6 +901,8 @@ public: Delete(source); } + Swig_director_emit_dynamic_cast(n, f); + /* Insert constraint checking code */ for (p = l; p;) { if ((tm = Getattr(p, "tmap:check"))) { @@ -854,7 +985,7 @@ public: /* Error handling code */ Printf(f->code, "fail:\n"); Printv(f->code, cleanup, NIL); - Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL); + Printv(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL); Printf(f->code, "}\n"); @@ -903,7 +1034,7 @@ public: // Method or static method or plain function. const char *methodname = 0; String *output = s_oowrappers; - if (newobject) { + if (constructor) { class_has_ctor = true; methodname = "__construct"; } else if (wrapperType == memberfn) { @@ -1346,9 +1477,20 @@ public: while (last_handled_i < i) { Printf(prepare, "case %d: ", ++last_handled_i); } - if (Cmp(d, "void") != 0) - Printf(prepare, "$r="); - Printf(prepare, "%s(%s); break;\n", iname, invoke_args); + if (Cmp(d, "void") != 0) { + if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) { + Append(prepare, "$r="); + } else { + Printf(prepare, "$this->%s=", SWIG_PTR); + } + } + if (!directorsEnabled() || !Swig_directorclass(n) || !newobject) { + Printf(prepare, "%s(%s); break;\n", iname, invoke_args); + } else if (!i) { + Printf(prepare, "%s($_this%s); break;\n", iname, invoke_args); + } else { + Printf(prepare, "%s($_this, %s); break;\n", iname, invoke_args); + } } if (i || wrapperType == memberfn) Printf(invoke_args, ","); @@ -1357,9 +1499,18 @@ public: Printf(prepare, "\t\t"); if (had_a_case) Printf(prepare, "default: "); - if (Cmp(d, "void") != 0) - Printf(prepare, "$r="); - Printf(prepare, "%s(%s);\n", iname, invoke_args); + if (Cmp(d, "void") != 0) { + if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) { + Append(prepare, "$r="); + } else { + Printf(prepare, "$this->%s=", SWIG_PTR); + } + } + if (!directorsEnabled() || !Swig_directorclass(n) || !newobject) { + Printf(prepare, "%s(%s);\n", iname, invoke_args); + } else { + Printf(prepare, "%s($_this, %s);\n", iname, invoke_args); + } if (had_a_case) Printf(prepare, "\t\t}\n"); Delete(invoke_args); @@ -1368,10 +1519,9 @@ public: Printf(output, "\n"); // If it's a member function or a class constructor... - if (wrapperType == memberfn || (newobject && current_class)) { - // We don't need this code if the wrapped class has a copy ctor - // since the flat function new_CLASSNAME will handle it for us. - if (newobject && !Getattr(current_class, "allocate:copy_constructor")) { + if (wrapperType == memberfn || (constructor && current_class)) { + String *acc = Getattr(n, "access"); + if (constructor) { const char * arg0; if (max_num_of_arguments > 0) { arg0 = Char(arg_names[0]); @@ -1382,29 +1532,40 @@ public: } SwigType *t = Getattr(current_class, "classtype"); String *mangled_type = SwigType_manglestr(SwigType_ltype(t)); - Printf(output, "\tfunction %s(%s) {\n", methodname, args); - Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) == '_p%s') {\n", arg0, arg0, mangled_type); + Printf(output, "\t%s function %s(%s) {\n", acc, methodname, args); + Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '_p%s') {\n", arg0, arg0, mangled_type); Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0); Printf(output, "\t\t\treturn;\n"); Printf(output, "\t\t}\n"); } else { - Printf(output, "\tfunction %s(%s) {\n", methodname, args); + Printf(output, "\t%s function %s(%s) {\n", acc, methodname, args); } } else { Printf(output, "\tstatic function %s(%s) {\n", methodname, args); } - Delete(args); - args = NULL; - for (int i = 0; i < max_num_of_arguments; ++i) { - Delete(arg_names[i]); - } - free(arg_names); - arg_names = NULL; - - Printf(output, "%s", prepare); - if (newobject) { - Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke); + if (!newobject) + Printf(output, "%s", prepare); + if (constructor) { + if (!directorsEnabled() || !Swig_directorclass(n)) { + Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke); + } else { + Node *parent = Swig_methodclass(n); + String *classname = Swig_class_name(parent); + Printf(output, "\t\tif (get_class($this) === '%s') {\n", classname); + Printf(output, "\t\t\t$_this = null;\n"); + Printf(output, "\t\t} else {\n"); + Printf(output, "\t\t\t$_this = $this;\n"); + Printf(output, "\t\t}\n"); + if (!Len(prepare)) { + if (num_arguments > 1) { + Printf(output, "\t\t$this->%s=%s($_this, %s);\n", SWIG_PTR, iname, args); + } else { + Printf(output, "\t\t$this->%s=%s($_this);\n", SWIG_PTR, iname); + } + } + } + Printf(output, "%s", prepare); } else if (Cmp(d, "void") == 0) { if (Cmp(invoke, "$r") != 0) Printf(output, "\t\t%s;\n", invoke); @@ -1412,7 +1573,31 @@ public: if (Cmp(invoke, "$r") != 0) Printf(output, "\t\t$r=%s;\n", invoke); if (Len(ret_types) == 1) { - Printf(output, "\t\treturn is_resource($r) ? new %s%s($r) : $r;\n", prefix, Getattr(classLookup(d), "sym:name")); + /* If it has an abstract base, then we can't create a new + * base object. */ + int hasabstractbase = 0; + Node *bases = Getattr(Swig_methodclass(n), "bases"); + if (bases) { + Iterator i = First(bases); + while(i.item) { + if (Getattr(i.item, "abstract")) { + hasabstractbase = 1; + break; + } + i = Next(i); + } + } + if (newobject || !hasabstractbase) { + /* + * _p_Foo -> Foo, _p_ns__Bar -> Bar + * TODO: do this in a more elegant way + */ + Printf(output, "\t\tif (is_resource($r)) $class='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); + Printf(output, "\t\treturn is_resource($r) ? new $class($r) : $r;\n"); + } else { + Printf(output, "\t\t$this->%s = $r;\n", SWIG_PTR); + Printf(output, "\t\treturn $this;\n"); + } } else { Printf(output, "\t\tif (!is_resource($r)) return $r;\n"); Printf(output, "\t\tswitch (get_resource_type($r)) {\n"); @@ -1455,6 +1640,15 @@ public: Delete(prepare); Delete(invoke); free(arg_values); + + Delete(args); + args = NULL; + + for (int i = 0; i < max_num_of_arguments; ++i) { + Delete(arg_names[i]); + } + free(arg_names); + arg_names = NULL; } DelWrapper(f); @@ -1587,7 +1781,7 @@ public: * Pragma directive. * * %pragma(php) code="String" # Includes a string in the .php file - * %pragma(php) include="file.pl" # Includes a file in the .php file + * %pragma(php) include="file.php" # Includes a file in the .php file */ virtual int pragmaDirective(Node *n) { @@ -1698,53 +1892,57 @@ public: } Printf(s_phpclasses, "class %s%s ", prefix, shadow_classname); + String *baseclass = NULL; if (base.item) { - String *baseclass = Getattr(base.item, "sym:name"); + baseclass = Getattr(base.item, "sym:name"); if (!baseclass) baseclass = Getattr(base.item, "name"); Printf(s_phpclasses, "extends %s%s ", prefix, baseclass); + } else if (GetFlag(n, "feature:exceptionclass")) { + Append(s_phpclasses, "extends Exception "); } Printf(s_phpclasses, "{\n\tpublic $%s=null;\n", SWIG_PTR); + Printf(s_phpclasses, "\tprotected $%s=array();\n", SWIG_DATA); // Write property SET handlers ki = First(shadow_set_vars); if (ki.key) { // This class has setters. - // FIXME: just ignore setting an unknown property name for now. Printf(s_phpclasses, "\n\tfunction __set($var,$value) {\n"); // FIXME: tune this threshold... if (Len(shadow_set_vars) <= 2) { // Not many setters, so avoid call_user_func. while (ki.key) { key = ki.key; - Printf(s_phpclasses, "\t\tif ($var == '%s') return %s($this->%s,$value);\n", key, ki.item, SWIG_PTR); + Printf(s_phpclasses, "\t\tif ($var === '%s') return %s($this->%s,$value);\n", key, ki.item, SWIG_PTR); ki = Next(ki); } } else { Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_set';\n", shadow_classname); - Printf(s_phpclasses, "\t\tif (function_exists($func)) call_user_func($func,$this->%s,$value);\n", SWIG_PTR); + Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s,$value);\n", SWIG_PTR); + } + Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_alter_newobject($this->%s,$value);\n", module, SWIG_PTR); + Printf(s_phpclasses, "\t\telse $this->%s[$var] = $value;\n", SWIG_DATA); + if (baseclass) { + Printf(s_phpclasses, "\t\treturn %s%s::__set($var,$value);\n", prefix, baseclass); } Printf(s_phpclasses, "\t}\n"); /* Create __isset for PHP 5.1 and later; PHP 5.0 will just ignore it. */ Printf(s_phpclasses, "\n\tfunction __isset($var) {\n"); - // FIXME: tune this threshold, but it should probably be different to - // that for __set() and __get() as we don't need to call_user_func() - // here... - if (Len(shadow_set_vars) == 1) { - // Only one setter, so just check the name. - Printf(s_phpclasses, "\t\treturn "); - while (ki.key) { - key = ki.key; - Printf(s_phpclasses, "$var == '%s'", ki.key); - ki = Next(ki); - if (ki.key) Printf(s_phpclasses, " || "); - } - Printf(s_phpclasses, ";\n"); - } else { - Printf(s_phpclasses, "\t\treturn function_exists('%s_'.$var.'_set');\n", shadow_classname); - } + Printf(s_phpclasses, "\t\tif (function_exists('%s_'.$var.'_set')) return true;\n", shadow_classname); + Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n"); + Printf(s_phpclasses, "\t\telse return array_key_exists($var, $this->%s);\n", SWIG_DATA); + Printf(s_phpclasses, "\t}\n"); + } else { + Printf(s_phpclasses, "\n\tfunction __set($var,$value) {\n"); + Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_alter_newobject($this->%s,$value);\n", module, SWIG_PTR); + Printf(s_phpclasses, "\t\telse $this->%s[$var] = $value;\n", SWIG_DATA); + Printf(s_phpclasses, "\t}\n"); + Printf(s_phpclasses, "\n\tfunction __isset($var) {\n"); + Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n"); + Printf(s_phpclasses, "\t\telse return array_key_exists($var, $this->%s);\n", SWIG_DATA); Printf(s_phpclasses, "\t}\n"); } // Write property GET handlers @@ -1758,15 +1956,26 @@ public: // Not many getters, so avoid call_user_func. while (ki.key) { key = ki.key; - Printf(s_phpclasses, "\t\tif ($var == '%s') return %s($this->%s);\n", key, ki.item, SWIG_PTR); + Printf(s_phpclasses, "\t\tif ($var === '%s') return %s($this->%s);\n", key, ki.item, SWIG_PTR); ki = Next(ki); } } else { Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_get';\n", shadow_classname); Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s);\n", SWIG_PTR); } + Printf(s_phpclasses, "\t\telse if ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR); + Printf(s_phpclasses, "\t\telse if(array_key_exists($var, $this->%s)) return $this->%s[$var];\n", SWIG_DATA, SWIG_DATA); // Reading an unknown property name gives null in PHP. - Printf(s_phpclasses, "\t\treturn null;\n"); + if (base.item) { + Printf(s_phpclasses, "\t\treturn %s%s::__get($var);\n", prefix, baseclass); + } else { + Printf(s_phpclasses, "\t\treturn null;\n"); + } + Printf(s_phpclasses, "\t}\n"); + } else { + Printf(s_phpclasses, "\n\tfunction __get($var) {\n"); + Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_example_get_newobject($this->%s);\n", SWIG_PTR); + Printf(s_phpclasses, "\t\telse return $this->%s[$var];\n", SWIG_DATA); Printf(s_phpclasses, "\t}\n"); } @@ -1960,7 +2169,47 @@ public: virtual int constructorHandler(Node *n) { constructors++; - wrapperType = constructor; + if (Swig_directorclass(n)) { + String *name = GetChar(Swig_methodclass(n), "name"); + String *ctype = GetChar(Swig_methodclass(n), "classtype"); + String *sname = GetChar(Swig_methodclass(n), "sym:name"); + String *args = NewStringEmpty(); + ParmList *p = Getattr(n, "parms"); + int i; + + for (i = 0; p; p = nextSibling(p), i++) { + if (i) { + Printf(args, ", "); + } + if (Strcmp(GetChar(p, "type"), SwigType_str(GetChar(p, "type"), 0))) { + SwigType *t = Getattr(p, "type"); + Printf(args, "%s", SwigType_rcaststr(t, 0)); + if (SwigType_isreference(t)) { + Append(args, "*"); + } + } + Printf(args, "arg%d", i+1); + } + + /* director ctor code is specific for each class */ + Delete(director_ctor_code); + director_ctor_code = NewStringEmpty(); + director_prot_ctor_code = NewStringEmpty(); + Printf(director_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n"); + Printf(director_prot_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n"); + Printf(director_ctor_code, " result = (%s *)new %s(%s);\n", ctype, ctype, args); + Printf(director_prot_ctor_code, " SWIG_PHP_Error(E_ERROR, \"accessing abstract class or protected constructor\");\n", name, name, args); + if (i) { + Insert(args, 0, ", "); + } + Printf(director_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s);\n}\n", ctype, sname, args); + Printf(director_prot_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s);\n}\n", ctype, sname, args); + Delete(args); + + wrapperType = directorconstructor; + } else { + wrapperType = constructor; + } Language::constructorHandler(n); wrapperType = standard; @@ -2013,6 +2262,9 @@ public: Append(f->code, actioncode); Delete(actioncode); + Append(f->code, "return;\n"); + Append(f->code, "fail:\n"); + Append(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n"); Printf(f->code, "}\n"); Wrapper_print(f, s_wrappers); @@ -2031,6 +2283,397 @@ public: return SWIG_OK; } + int classDirectorInit(Node *n) { + String *declaration = Swig_director_declaration(n); + Printf(f_directors_h, "%s\n", declaration); + Printf(f_directors_h, "public:\n"); + Delete(declaration); + return Language::classDirectorInit(n); + } + + int classDirectorEnd(Node *n) { + Printf(f_directors_h, "};\n"); + return Language::classDirectorEnd(n); + } + + int classDirectorConstructor(Node *n) { + Node *parent = Getattr(n, "parentNode"); + String *decl = Getattr(n, "decl"); + String *supername = Swig_class_name(parent); + String *classname = NewStringEmpty(); + Printf(classname, "SwigDirector_%s", supername); + + /* insert self parameter */ + Parm *p; + ParmList *superparms = Getattr(n, "parms"); + ParmList *parms = CopyParmList(superparms); + String *type = NewString("zval"); + SwigType_add_pointer(type); + p = NewParm(type, NewString("self")); + set_nextSibling(p, parms); + parms = p; + + if (!Getattr(n, "defaultargs")) { + /* constructor */ + { + Wrapper *w = NewWrapper(); + String *call; + String *basetype = Getattr(parent, "classtype"); + String *target = Swig_method_decl(0, decl, classname, parms, 0, 0); + call = Swig_csuperclass_call(0, basetype, superparms); + Printf(w->def, "%s::%s: %s, Swig::Director(self) {", classname, target, call); + Append(w->def, "}"); + Delete(target); + Wrapper_print(w, f_directors); + Delete(call); + DelWrapper(w); + } + + /* constructor header */ + { + String *target = Swig_method_decl(0, decl, classname, parms, 0, 1); + Printf(f_directors_h, " %s;\n", target); + Delete(target); + } + } + return Language::classDirectorConstructor(n); + } + + int classDirectorDefaultConstructor(Node *n) { + return Language::classDirectorDefaultConstructor(n); + } + + int classDirectorMethod(Node *n, Node *parent, String *super) { + int is_void = 0; + int is_pointer = 0; + String *decl; + String *type; + String *name; + String *classname; + String *c_classname = Getattr(parent, "name"); + String *declaration; + ParmList *l; + Wrapper *w; + String *tm; + String *wrap_args = NewStringEmpty(); + String *return_type; + String *value = Getattr(n, "value"); + String *storage = Getattr(n, "storage"); + bool pure_virtual = false; + int status = SWIG_OK; + int idx; + bool ignored_method = GetFlag(n, "feature:ignore") ? true : false; + + if (Cmp(storage, "virtual") == 0) { + if (Cmp(value, "0") == 0) { + pure_virtual = true; + } + } + + classname = Getattr(parent, "sym:name"); + type = Getattr(n, "type"); + name = Getattr(n, "name"); + + w = NewWrapper(); + declaration = NewStringEmpty(); + + /* determine if the method returns a pointer */ + decl = Getattr(n, "decl"); + is_pointer = SwigType_ispointer_return(decl); + is_void = (Cmp(type, "void") == 0 && !is_pointer); + + /* form complete return type */ + return_type = Copy(type); + { + SwigType *t = Copy(decl); + SwigType *f = SwigType_pop_function(t); + SwigType_push(return_type, t); + Delete(f); + Delete(t); + } + + /* virtual method definition */ + l = Getattr(n, "parms"); + String *target; + String *pclassname = NewStringf("SwigDirector_%s", classname); + String *qualified_name = NewStringf("%s::%s", pclassname, name); + SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type; + target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0); + Printf(w->def, "%s", target); + Delete(qualified_name); + Delete(target); + /* header declaration */ + target = Swig_method_decl(rtype, decl, name, l, 0, 1); + Printf(declaration, " virtual %s", target); + Delete(target); + + // Get any exception classes in the throws typemap + ParmList *throw_parm_list = 0; + + if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { + Parm *p; + int gencomma = 0; + + Append(w->def, " throw("); + Append(declaration, " throw("); + + if (throw_parm_list) + Swig_typemap_attach_parms("throws", throw_parm_list, 0); + for (p = throw_parm_list; p; p = nextSibling(p)) { + if ((tm = Getattr(p, "tmap:throws"))) { + if (gencomma++) { + Append(w->def, ", "); + Append(declaration, ", "); + } + String *str = SwigType_str(Getattr(p, "type"), 0); + Append(w->def, str); + Append(declaration, str); + Delete(str); + } + } + + Append(w->def, ")"); + Append(declaration, ")"); + } + + Append(w->def, " {"); + Append(declaration, ";\n"); + + /* declare method return value + * if the return value is a reference or const reference, a specialized typemap must + * handle it, including declaration of c_result ($result). + */ + if (!is_void) { + if (!(ignored_method && !pure_virtual)) { + String *cres = SwigType_lstr(return_type, "c_result"); + Printf(w->code, "%s;\n", cres); + Delete(cres); + } + } + + if (ignored_method) { + if (!pure_virtual) { + if (!is_void) + Printf(w->code, "return "); + String *super_call = Swig_method_call(super, l); + Printf(w->code, "%s;\n", super_call); + Delete(super_call); + } else { + Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname), + SwigType_namestr(name)); + } + } else { + /* attach typemaps to arguments (C/C++ -> PHP) */ + String *parse_args = NewStringEmpty(); + + /* remove the wrapper 'w' since it was producing spurious temps */ + Swig_typemap_attach_parms("in", l, 0); + Swig_typemap_attach_parms("directorin", l, 0); + Swig_typemap_attach_parms("directorargout", l, w); + + Parm *p; + char source[256]; + + int outputs = 0; + if (!is_void) + outputs++; + + /* build argument list and type conversion string */ + idx = 0; + p = l; + int use_parse = 0; + while (p != NULL) { + if (checkAttribute(p, "tmap:in:numinputs", "0")) { + p = Getattr(p, "tmap:in:next"); + continue; + } + + if (Getattr(p, "tmap:directorargout") != 0) + outputs++; + + String *pname = Getattr(p, "name"); + String *ptype = Getattr(p, "type"); + + if ((tm = Getattr(p, "tmap:directorin")) != 0) { + String *parse = Getattr(p, "tmap:directorin:parse"); + if (!parse) { + sprintf(source, "obj%d", idx++); + String *input = NewStringf("&%s", source); + Replaceall(tm, "$input", input); + Delete(input); + Replaceall(tm, "$owner", "0"); + Printv(wrap_args, "zval ", source, ";\n", NIL); + Printf(wrap_args, "args[%d] = &%s;\n", idx - 1, source); + + Printv(wrap_args, tm, "\n", NIL); + Putc('O', parse_args); + } else { + use_parse = 1; + Append(parse_args, parse); + Replaceall(tm, "$input", pname); + Replaceall(tm, "$owner", "0"); + if (Len(tm) == 0) + Append(tm, pname); + } + p = Getattr(p, "tmap:directorin:next"); + continue; + } else if (Cmp(ptype, "void")) { + Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file, line_number, + "Unable to use type %s as a function argument in director method %s::%s (skipping method).\n", SwigType_str(ptype, 0), + SwigType_namestr(c_classname), SwigType_namestr(name)); + status = SWIG_NOWRAP; + break; + } + p = nextSibling(p); + } + Append(w->code, "int error;\n"); + if (!idx) { + Printf(w->code, "zval **args = NULL;\n", idx); + } else { + Printf(w->code, "zval *args[%d];\n", idx); + } + Append(w->code, "zval *result, funcname;\n"); + Append(w->code, "MAKE_STD_ZVAL(result);\n"); + Printf(w->code, "ZVAL_STRING(&funcname, (char *)\"%s\", 0);\n", name); + Append(w->code, "if (!swig_self) {\n"); + Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");"); + Append(w->code, "}\n\n"); + + /* wrap complex arguments to zvals */ + Printv(w->code, wrap_args, NIL); + + Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,\n"); + Printf(w->code, " result, %d, args TSRMLS_CC);\n", idx); + + /* exception handling */ + tm = Swig_typemap_lookup("director:except", n, "result", 0); + if (!tm) { + tm = Getattr(n, "feature:director:except"); + if (tm) + tm = Copy(tm); + } + if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { + Replaceall(tm, "$error", "error"); + Printv(w->code, Str(tm), "\n", NIL); + } + Delete(tm); + + /* marshal return value from PHP to C/C++ type */ + + String *cleanup = NewStringEmpty(); + String *outarg = NewStringEmpty(); + + idx = 0; + + /* marshal return value */ + if (!is_void) { + /* this seems really silly. the node's type excludes + * qualifier/pointer/reference markers, which have to be retrieved + * from the decl field to construct return_type. but the typemap + * lookup routine uses the node's type, so we have to swap in and + * out the correct type. it's not just me, similar silliness also + * occurs in Language::cDeclaration(). + */ + Setattr(n, "type", return_type); + tm = Swig_typemap_lookup("directorout", n, "result", w); + Setattr(n, "type", type); + if (tm != 0) { + Replaceall(tm, "$input", "&result"); + char temp[24]; + sprintf(temp, "%d", idx); + Replaceall(tm, "$argnum", temp); + + /* TODO check this */ + if (Getattr(n, "wrap:disown")) { + Replaceall(tm, "$disown", "SWIG_POINTER_DISOWN"); + } else { + Replaceall(tm, "$disown", "0"); + } + Replaceall(tm, "$result", "c_result"); + Printv(w->code, tm, "\n", NIL); + Delete(tm); + } else { + Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number, + "Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(return_type, 0), SwigType_namestr(c_classname), + SwigType_namestr(name)); + status = SWIG_ERROR; + } + } + + /* marshal outputs */ + for (p = l; p;) { + if ((tm = Getattr(p, "tmap:directorargout")) != 0) { + Replaceall(tm, "$input", "result"); + Replaceall(tm, "$result", Getattr(p, "name")); + Printv(w->code, tm, "\n", NIL); + p = Getattr(p, "tmap:directorargout:next"); + } else { + p = nextSibling(p); + } + } + + Append(w->code, "FREE_ZVAL(result);\n"); + + Delete(parse_args); + Delete(cleanup); + Delete(outarg); + } + + if (!is_void) { + if (!(ignored_method && !pure_virtual)) { + String *rettype = SwigType_str(return_type, 0); + if (!SwigType_isreference(return_type)) { + Printf(w->code, "return (%s) c_result;\n", rettype); + } else { + Printf(w->code, "return (%s) *c_result;\n", rettype); + } + Delete(rettype); + } + } else { + Append(w->code, "return;\n"); + } + + Append(w->code, "fail:\n"); + Append(w->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n"); + Append(w->code, "}\n"); + + // We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method + String *inline_extra_method = NewStringEmpty(); + if (dirprot_mode() && !is_public(n) && !pure_virtual) { + Printv(inline_extra_method, declaration, NIL); + String *extra_method_name = NewStringf("%sSwigPublic", name); + Replaceall(inline_extra_method, name, extra_method_name); + Replaceall(inline_extra_method, ";\n", " {\n "); + if (!is_void) + Printf(inline_extra_method, "return "); + String *methodcall = Swig_method_call(super, l); + Printv(inline_extra_method, methodcall, ";\n }\n", NIL); + Delete(methodcall); + Delete(extra_method_name); + } + + /* emit the director method */ + if (status == SWIG_OK) { + if (!Getattr(n, "defaultargs")) { + Wrapper_print(w, f_directors); + Printv(f_directors_h, declaration, NIL); + Printv(f_directors_h, inline_extra_method, NIL); + } + } + + /* clean up */ + Delete(wrap_args); + Delete(return_type); + Delete(pclassname); + DelWrapper(w); + return status; + } + + int classDirectorDisown(Node *n) { + /* avoid a warning */ + n = n; + return SWIG_OK; + } }; /* class PHP */ static PHP *maininstance = 0; From 413f114eda3879e8cb35291372cb55f243fa20fc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 26 Jul 2009 21:21:26 +0000 Subject: [PATCH 051/352] fix some overloaded warning messages when templates are used git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11454 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/allegrocl.cxx | 24 ++++++++++-------------- Source/Modules/overload.cxx | 4 ++-- Source/Modules/r.cxx | 28 ++++++++++------------------ Source/Swig/naming.c | 2 +- 4 files changed, 23 insertions(+), 35 deletions(-) diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 91bfdf2ea..1cccca69f 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1803,13 +1803,13 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { String *t2 = Getattr(p2, "tmap:typecheck:precedence"); if ((!t1) && (!nodes[i].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), - "Overloaded %s(%s) not supported (no type checking rule for '%s').\n", - Getattr(nodes[i].n, "name"), ParmList_str_defaultargs(Getattr(nodes[i].n, "parms")), SwigType_str(Getattr(p1, "type"), 0)); + "Overloaded method %s not supported (no type checking rule for '%s').\n", + Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); nodes[i].error = 1; } else if ((!t2) && (!nodes[j].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded %s(%s) not supported (no type checking rule for '%s').\n", - Getattr(nodes[j].n, "name"), ParmList_str_defaultargs(Getattr(nodes[j].n, "parms")), SwigType_str(Getattr(p2, "type"), 0)); + "Overloaded method %s not supported (no type checking rule for '%s').\n", + Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); nodes[j].error = 1; } if (t1 && t2) { @@ -1937,19 +1937,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded %s(%s)%s is shadowed by %s(%s)%s at %s:%d.\n", - Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), - SwigType_isconst(Getattr(nodes[j].n, "decl")) ? " const" : "", - Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms), - SwigType_isconst(Getattr(nodes[i].n, "decl")) ? " const" : "", Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s is shadowed by %s at %s:%d.\n", + Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), + Getfile(nodes[i].n), Getline(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s(%s)%s ignored. Method %s(%s)%s at %s:%d used.\n", - Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), - SwigType_isconst(Getattr(nodes[j].n, "decl")) ? " const" : "", - Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms), - SwigType_isconst(Getattr(nodes[i].n, "decl")) ? " const" : "", Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored. Method %s at %s:%d used.\n", + Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), + Getfile(nodes[i].n), Getline(nodes[i].n)); } nodes[j].error = 1; } diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 79656517a..6dfa5e712 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -126,12 +126,12 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { String *t2 = Getattr(p2, "tmap:typecheck:precedence"); if ((!t1) && (!nodes[i].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), - "Overloaded method %s not supported (no type checking rule for '%s').\n", + "xx Overloaded method %s not supported (no type checking rule for '%s').\n", Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); nodes[i].error = 1; } else if ((!t2) && (!nodes[j].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s not supported (no type checking rule for '%s').\n", + "yy Overloaded method %s not supported (no type checking rule for '%s').\n", Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); nodes[j].error = 1; } diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 8e9aa557d..c48e2e266 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1418,15 +1418,13 @@ static List * Swig_overload_rank(Node *n, String *t2 = Getattr(p2,"tmap:typecheck:precedence"); if ((!t1) && (!nodes[i].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), - "Overloaded %s(%s) not supported (no type checking rule for '%s').\n", - Getattr(nodes[i].n,"name"),ParmList_str_defaultargs(Getattr(nodes[i].n,"parms")), - SwigType_str(Getattr(p1,"type"),0)); + "Overloaded method %s not supported (no type checking rule for '%s').\n", + Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); nodes[i].error = 1; } else if ((!t2) && (!nodes[j].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded %s(%s) not supported (no type checking rule for '%s').\n", - Getattr(nodes[j].n,"name"),ParmList_str_defaultargs(Getattr(nodes[j].n,"parms")), - SwigType_str(Getattr(p2,"type"),0)); + "xx Overloaded method %s not supported (no type checking rule for '%s').\n", + Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); nodes[j].error = 1; } if (t1 && t2) { @@ -1556,21 +1554,15 @@ static List * Swig_overload_rank(Node *n, if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded %s(%s)%s is shadowed by %s(%s)%s at %s:%d.\n", - Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms), - SwigType_isconst(Getattr(nodes[j].n,"decl")) ? " const" : "", - Getattr(nodes[i].n,"name"), ParmList_errorstr(nodes[i].parms), - SwigType_isconst(Getattr(nodes[i].n,"decl")) ? " const" : "", - Getfile(nodes[i].n),Getline(nodes[i].n)); + "Overloaded method %s is shadowed by %s at %s:%d.\n", + Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), + Getfile(nodes[i].n), Getline(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s(%s)%s ignored. Method %s(%s)%s at %s:%d used.\n", - Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms), - SwigType_isconst(Getattr(nodes[j].n,"decl")) ? " const" : "", - Getattr(nodes[i].n,"name"), ParmList_errorstr(nodes[i].parms), - SwigType_isconst(Getattr(nodes[i].n,"decl")) ? " const" : "", - Getfile(nodes[i].n),Getline(nodes[i].n)); + "Overloaded method %s ignored. Method %s at %s:%d used.\n", + Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), + Getfile(nodes[i].n), Getline(nodes[i].n)); } nodes[j].error = 1; } diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 013ce5929..d69eb4225 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1611,7 +1611,7 @@ String *Swig_name_decl(Node *n) { qname = NewString(""); if (qualifier && Len(qualifier) > 0) Printf(qname, "%s::", qualifier); - Printf(qname, "%s", name); + Printf(qname, "%s", SwigType_str(name, 0)); decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : ""); From 82312aacf8bc110d2fc639d33afa95e4eabaf046 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 26 Jul 2009 21:29:55 +0000 Subject: [PATCH 052/352] remove some debugging cruft git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11455 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/overload.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 6dfa5e712..79656517a 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -126,12 +126,12 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { String *t2 = Getattr(p2, "tmap:typecheck:precedence"); if ((!t1) && (!nodes[i].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n), - "xx Overloaded method %s not supported (no type checking rule for '%s').\n", + "Overloaded method %s not supported (no type checking rule for '%s').\n", Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0)); nodes[i].error = 1; } else if ((!t2) && (!nodes[j].error)) { Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n), - "yy Overloaded method %s not supported (no type checking rule for '%s').\n", + "Overloaded method %s not supported (no type checking rule for '%s').\n", Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0)); nodes[j].error = 1; } From 0fa227ea8339b88328ce531a81bff69b52994c1d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 28 Jul 2009 11:47:36 +0000 Subject: [PATCH 053/352] PHP: fix for the director_using testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11459 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 ++++ Examples/test-suite/director_using.i | 2 ++ Source/Include/swigwarn.h | 1 + Source/Modules/php.cxx | 44 +++++++++++++++++++++++++++- 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index ece581863..f2b3fc6ef 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.40 (in progress) ============================ +2009-07-28: vmiklos + [PHP] If a member function is not public but it has a base + which is public, then now a warning is issued and the member + function will be public, as PHP requires this. + 2009-07-21: vmiklos [PHP] Director support added. diff --git a/Examples/test-suite/director_using.i b/Examples/test-suite/director_using.i index 104528ca4..9001ffbb9 100644 --- a/Examples/test-suite/director_using.i +++ b/Examples/test-suite/director_using.i @@ -1,5 +1,7 @@ %module(directors="1",dirprot="1") director_using +%warnfilter(SWIGWARN_PHP_PUBLIC_BASE) FooBar; + %{ #include #include diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 5be0305fa..e8fa159af 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -250,6 +250,7 @@ #define WARN_PHP_MULTIPLE_INHERITANCE 870 #define WARN_PHP_UNKNOWN_PRAGMA 871 +#define WARN_PHP_PUBLIC_BASE 872 /* please leave 870-889 free for PHP */ diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 8d65df889..2c6168b06 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1520,7 +1520,48 @@ public: Printf(output, "\n"); // If it's a member function or a class constructor... if (wrapperType == memberfn || (constructor && current_class)) { - String *acc = Getattr(n, "access"); + String *acc = NewString(Getattr(n, "access")); + // If a base has the same method with public access, then PHP + // requires to have it here as public as well + Node *bases = Getattr(Swig_methodclass(n), "bases"); + if (bases && Strcmp(acc, "public") != 0) { + String *warnmsg = 0; + int haspublicbase = 0; + Iterator i = First(bases); + while (i.item) { + Node *j = firstChild(i.item); + while (j) { + if (Strcmp(Getattr(j, "name"), Getattr(n, "name")) != 0) { + j = nextSibling(j); + continue; + } + if (Strcmp(nodeType(j), "cdecl") == 0) { + if (!Getattr(j, "access") || checkAttribute(j, "access", "public")) { + haspublicbase = 1; + } + } else if (Strcmp(nodeType(j), "using") == 0 && firstChild(j) && Strcmp(nodeType(firstChild(j)), "cdecl") == 0) { + if (!Getattr(firstChild(j), "access") || checkAttribute(firstChild(j), "access", "public")) { + haspublicbase = 1; + } + } + if (haspublicbase) { + warnmsg = NewStringf("Modifying the access of '%s::%s' to public, as the base '%s' has it as public as well.\n", Getattr(current_class, "classtype"), Getattr(n, "name"), Getattr(i.item, "classtype")); + break; + } + j = nextSibling(j); + } + i = Next(i); + if (haspublicbase) { + break; + } + } + if (Getattr(n, "access") && haspublicbase) { + Delete(acc); + acc = NewString("public"); + Swig_warning(WARN_PHP_PUBLIC_BASE, input_file, line_number, Char(warnmsg)); + Delete(warnmsg); + } + } if (constructor) { const char * arg0; if (max_num_of_arguments > 0) { @@ -1540,6 +1581,7 @@ public: } else { Printf(output, "\t%s function %s(%s) {\n", acc, methodname, args); } + Delete(acc); } else { Printf(output, "\tstatic function %s(%s) {\n", methodname, args); } From c321421bc572f281460d229d889018b48e791983 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 28 Jul 2009 13:12:06 +0000 Subject: [PATCH 054/352] [PHP] Update warnings about clashes between identifiers and PHP keywords and automatic renaming to work with the PHP5 class wrappers. Fixes SF#1613679. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11460 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Examples/test-suite/name_warnings.i | 2 ++ Examples/test-suite/operator_overload_break.i | 3 +-- Examples/test-suite/php/Makefile.in | 4 ++-- Examples/test-suite/template_default.i | 7 +++---- Examples/test-suite/template_default2.i | 8 ++++---- Lib/php/phpkw.swg | 12 +++--------- Source/Modules/php.cxx | 3 --- 8 files changed, 20 insertions(+), 24 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index f2b3fc6ef..63928fede 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.40 (in progress) ============================ +2009-07-28: olly + [PHP] Update warnings about clashes between identifiers and PHP + keywords and automatic renaming to work with the PHP5 class + wrappers. Fixes SF#1613679. + 2009-07-28: vmiklos [PHP] If a member function is not public but it has a base which is public, then now a warning is issued and the member diff --git a/Examples/test-suite/name_warnings.i b/Examples/test-suite/name_warnings.i index 527dbcfaa..4032f20e1 100644 --- a/Examples/test-suite/name_warnings.i +++ b/Examples/test-suite/name_warnings.i @@ -35,7 +35,9 @@ namespace std { 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; diff --git a/Examples/test-suite/operator_overload_break.i b/Examples/test-suite/operator_overload_break.i index 0893da786..9c6927bb0 100644 --- a/Examples/test-suite/operator_overload_break.i +++ b/Examples/test-suite/operator_overload_break.i @@ -12,7 +12,6 @@ %rename(PlusPlusPostfix) operator++(int); #endif - %{ #include using namespace std; @@ -56,7 +55,7 @@ public: Op& operator++() {k++; return *this;} - void Print() {std::cerr << k << std::endl;} + void PrintK() {std::cerr << k << std::endl;} int k; }; diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index 679b46b54..ae1b78bf8 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -8,8 +8,8 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -#CPP_TEST_CASES += \ -# php_namewarn_rename \ +CPP_TEST_CASES += \ + php_namewarn_rename \ include $(srcdir)/../common.mk diff --git a/Examples/test-suite/template_default.i b/Examples/test-suite/template_default.i index 2f6ffd5ba..d771ef09e 100644 --- a/Examples/test-suite/template_default.i +++ b/Examples/test-suite/template_default.i @@ -1,8 +1,7 @@ %module template_default - - %warnfilter(SWIGWARN_RUBY_WRONG_NAME) ns1::Traits::c; /* Ruby, wrong constant name */ + namespace ns1 { namespace ns2 { @@ -154,8 +153,8 @@ namespace ns1 { %} -%template(Do) ns1::ns4::D; -%template(Bo) ns1::ns4::Base >; +%template(Doo) ns1::ns4::D; +%template(Boo) ns1::ns4::Base >; diff --git a/Examples/test-suite/template_default2.i b/Examples/test-suite/template_default2.i index 1e0b6240d..9ba0455f1 100644 --- a/Examples/test-suite/template_default2.i +++ b/Examples/test-suite/template_default2.i @@ -8,7 +8,7 @@ enum Polarization { UnaryPolarization, BinaryPolarization }; template - struct Interface + struct Interface_tpl { }; @@ -19,7 +19,7 @@ template > // **** problem here ***** + class Base = Interface_tpl

      > // **** problem here ***** struct Module : Base { }; @@ -29,12 +29,12 @@ namespace oss { - %template(Interface_UP) Interface; + %template(Interface_UP) Interface_tpl; // This works %template(Module_UP1) Module >; + Interface_tpl >; // These don't %template(Module_UP2) Module; diff --git a/Lib/php/phpkw.swg b/Lib/php/phpkw.swg index af1a8f825..301597eb7 100644 --- a/Lib/php/phpkw.swg +++ b/Lib/php/phpkw.swg @@ -3,19 +3,13 @@ * of SWIG, and the README file for authors - http://www.swig.org/release.html. * * phpkw.swg - * - * The 'keywords' in PHP are global, ie, the following names are fine - * when used as class methods. * ----------------------------------------------------------------------------- */ -#define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s", rename="c_%s",fullname=1) `x` +#define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",$isclass,rename="c_%s") `x` -%define PHPCN(x) -%keywordwarn("'" `x` "' is a PHP reserved class name, class renamed as 'c_" `x` "'",%$isclass,rename="c_%s") `x`; -%keywordwarn("'" `x` "' is a PHP reserved class name, constructor renamed as 'c_" `x` "'",%$isconstructor,rename="c_%s") `x`; -%enddef +#define PHPCN(x) %keywordwarn("'" `x` "' is a PHP reserved class name, class renamed as 'c_" `x` "'",%$isclass,rename="c_%s") `x` -#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP",sourcefmt="%(lower)s",fullname=1) `x` +#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP",sourcefmt="%(lower)s") `x` #define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP") "::" `x` diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 2c6168b06..235b3f5a0 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -12,9 +12,6 @@ * * Short term: * - * Sort out auto-renaming of method and class names which are reserved - * words (e.g. empty, clone, exception, etc.) - * * Sort out wrapping of static member variables in OO PHP5. * * Medium term: From 4b7478ac15490e13dac674ec64f2352ea14f6772 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 29 Jul 2009 02:06:18 +0000 Subject: [PATCH 055/352] [PHP] Fix memory leak in PHP resource destructor for classes without a destructor and non-class types. Patch from Hitoshi Amano in SF#2825303. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11463 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Source/Modules/php.cxx | 2 ++ 2 files changed, 7 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 63928fede..f0c9cdd74 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.40 (in progress) ============================ +2009-07-29: olly + [PHP] Fix memory leak in PHP resource destructor for classes + without a destructor and non-class types. Patch from Hitoshi Amano + in SF#2825303. + 2009-07-28: olly [PHP] Update warnings about clashes between identifiers and PHP keywords and automatic renaming to work with the PHP5 class diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 235b3f5a0..078006462 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -158,9 +158,11 @@ void SwigPHP_emit_resource_registrations() { Printf(s_wrappers, " %s(rsrc, SWIGTYPE%s->name TSRMLS_CC);\n", destructor, key); } else { Printf(s_wrappers, " /* No destructor for class %s */\n", human_name); + Printf(s_wrappers, " efree(rsrc->ptr);\n"); } } else { Printf(s_wrappers, " /* No destructor for simple type %s */\n", key); + Printf(s_wrappers, " efree(rsrc->ptr);\n"); } // close function From 1f01eb5d7d59e21e479053333152d8e40af0459f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 29 Jul 2009 02:27:54 +0000 Subject: [PATCH 056/352] [PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi Amano in SF#2826322. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11464 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/php/utils.i | 1 + 2 files changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index f0c9cdd74..6fefd3f3c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-07-29: olly + [PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi + Amano in SF#2826322. + 2009-07-29: olly [PHP] Fix memory leak in PHP resource destructor for classes without a destructor and non-class types. Patch from Hitoshi Amano diff --git a/Lib/php/utils.i b/Lib/php/utils.i index becaf598a..f6fc2e5d2 100644 --- a/Lib/php/utils.i +++ b/Lib/php/utils.i @@ -53,6 +53,7 @@ t_output_helper( zval **target, zval *o) { } if ( (*target)->type == IS_NULL ) { REPLACE_ZVAL_VALUE(target,o,1); + FREE_ZVAL(o); return; } zval *tmp; From 0d539c8048bd659c7f81823fdc8a589e09c4def2 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 29 Jul 2009 03:34:22 +0000 Subject: [PATCH 057/352] [Python] Add missing locks to std::map wrappers. Patch from Paul Hampson in SF#2813836. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11465 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/python/std_map.i | 14 ++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6fefd3f3c..a0bad4885 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-07-29: olly + [Python] Add missing locks to std::map wrappers. Patch from + Paul Hampson in SF#2813836. + 2009-07-29: olly [PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi Amano in SF#2826322. diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index efe0e5e4c..074c43180 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -20,6 +20,7 @@ typedef std::map map_type; static int asptr(PyObject *obj, map_type **val) { int res = SWIG_ERROR; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (PyDict_Check(obj)) { SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); %#if PY_VERSION_HEX >= 0x03000000 @@ -32,6 +33,7 @@ res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info(),0); if (SWIG_IsOK(res) && val) *val = p; } + SWIG_PYTHON_THREAD_END_BLOCK; return res; } }; @@ -47,10 +49,10 @@ if (desc && desc->clientdata) { return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN); } else { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; size_type size = map.size(); int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1; if (pysize < 0) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; @@ -62,6 +64,7 @@ swig::SwigVar_PyObject val = swig::from(i->second); PyDict_SetItem(obj, key, val); } + SWIG_PYTHON_THREAD_END_BLOCK; return obj; } } @@ -165,8 +168,8 @@ PyObject* keys() { Map::size_type size = self->size(); int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; @@ -177,14 +180,15 @@ for (int j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(keyList, j, swig::from(i->first)); } + SWIG_PYTHON_THREAD_END_BLOCK; return keyList; } PyObject* values() { Map::size_type size = self->size(); int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; @@ -195,14 +199,15 @@ for (int j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(valList, j, swig::from(i->second)); } + SWIG_PYTHON_THREAD_END_BLOCK; return valList; } PyObject* items() { Map::size_type size = self->size(); int pysize = (size <= (Map::size_type) INT_MAX) ? (int) size : -1; + SWIG_PYTHON_THREAD_BEGIN_BLOCK; if (pysize < 0) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; PyErr_SetString(PyExc_OverflowError, "map size not valid in python"); SWIG_PYTHON_THREAD_END_BLOCK; @@ -213,6 +218,7 @@ for (int j = 0; j < pysize; ++i, ++j) { PyList_SET_ITEM(itemList, j, swig::from(*i)); } + SWIG_PYTHON_THREAD_END_BLOCK; return itemList; } From 22351914fe181db63743d29a593d4639fbb34f6a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 29 Jul 2009 11:03:22 +0000 Subject: [PATCH 058/352] PHP: Avoid calling is_resource() twice with no good reason git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11466 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 078006462..c14400f8a 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1633,8 +1633,10 @@ public: * _p_Foo -> Foo, _p_ns__Bar -> Bar * TODO: do this in a more elegant way */ - Printf(output, "\t\tif (is_resource($r)) $class='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); - Printf(output, "\t\treturn is_resource($r) ? new $class($r) : $r;\n"); + Printf(output, "\t\tif (is_resource($r)) {\n"); + Printf(output, "\t\t\t$class='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); + Printf(output, "\t\t\treturn new $class($r);\n\t\t}\n"); + Printf(output, "\t\telse return $r;\n"); } else { Printf(output, "\t\t$this->%s = $r;\n", SWIG_PTR); Printf(output, "\t\treturn $this;\n"); From b8d87475dbebafe4d511ad899c09b72ca29a248c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 29 Jul 2009 14:56:13 +0000 Subject: [PATCH 059/352] -I options belong in CPPFLAGS, not CFLAGS and CXXFLAGS. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11468 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Makefile.am | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/Makefile.am b/Source/Makefile.am index 84c595bc0..aadf50d28 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -8,7 +8,7 @@ BUILD_SOURCE_DIR=$(top_builddir)/Source SWIG_CXX_DEFS = @SWILL@ -AM_CFLAGS = -I$(BUILD_SOURCE_DIR)/Include \ +AM_CPPFLAGS = -I$(BUILD_SOURCE_DIR)/Include \ -I$(BUILD_SOURCE_DIR)/CParse \ -I$(SOURCE_DIR)/Include \ -I$(SOURCE_DIR)/DOH \ @@ -17,8 +17,7 @@ AM_CFLAGS = -I$(BUILD_SOURCE_DIR)/Include \ -I$(SOURCE_DIR)/Swig \ -I$(SOURCE_DIR)/Modules -AM_CXXFLAGS = $(AM_CFLAGS) \ - $(SWIG_CXX_DEFS) +AM_CXXFLAGS = $(SWIG_CXX_DEFS) AM_YFLAGS = -d From ae606df4df4d61d9bcf199e134fa5510f88a121b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 29 Jul 2009 16:17:04 +0000 Subject: [PATCH 060/352] PHP: fix for the allowexcept testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11469 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Source/Modules/php.cxx | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index a0bad4885..cc411774e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.40 (in progress) ============================ +2009-07-29: vmiklos + [PHP] Static member variables are now prefixed with the + class name. This allows static member variables with the + same name in different classes. + 2009-07-29: olly [Python] Add missing locks to std::map wrappers. Patch from Paul Hampson in SF#2813836. diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index c14400f8a..d64c04131 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2114,7 +2114,9 @@ public: } String *class_iname = Swig_name_member(Getattr(current_class, "sym:name"), iname); - create_command(iname, Swig_name_wrapper(class_iname)); + String *lclass_iname = NewStringf("%(lower)s", class_iname); + create_command(lclass_iname, Swig_name_wrapper(class_iname)); + Delete(lclass_iname); Wrapper *f = NewWrapper(); From bf0ee4471c02273da944f4858b46b45a15cc2f8d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 29 Jul 2009 20:50:39 +0000 Subject: [PATCH 061/352] (method, typelist) special variable macro fixed/enhanced and made official git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11470 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 + Doc/Manual/Contents.html | 12 +- Doc/Manual/Typemaps.html | 102 +++++- Examples/test-suite/common.mk | 1 + .../special_variable_functions_runme.cs | 18 ++ Examples/test-suite/csharp_prepost.i | 5 +- .../special_variable_functions_runme.java | 28 ++ .../special_variable_functions_runme.py | 12 + .../test-suite/special_variable_functions.i | 121 +++++++ Source/Modules/csharp.cxx | 18 +- Source/Modules/java.cxx | 18 +- Source/Modules/lang.cxx | 25 ++ Source/Modules/modula3.cxx | 17 +- Source/Modules/swigmod.h | 9 +- Source/Swig/scanner.c | 1 + Source/Swig/swig.h | 1 + Source/Swig/typemap.c | 300 ++++++++++-------- 17 files changed, 532 insertions(+), 161 deletions(-) create mode 100644 Examples/test-suite/csharp/special_variable_functions_runme.cs create mode 100644 Examples/test-suite/java/special_variable_functions_runme.java create mode 100644 Examples/test-suite/python/special_variable_functions_runme.py create mode 100644 Examples/test-suite/special_variable_functions.i diff --git a/CHANGES.current b/CHANGES.current index cc411774e..4fe0b3ff9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.40 (in progress) ============================ +2009-07-29: wsfulton + Add $typemap(method, typelist) special variable macro. This allows + the contents of a typemap to be inserted within another typemap. + Fully documented in Typemaps.html. + 2009-07-29: vmiklos [PHP] Static member variables are now prefixed with the class name. This allows static member variables with the diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index e997e46cb..ee19f9b73 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -337,13 +337,13 @@

    9. Typemap specifications -
    10. Pattern matching rules +
    11. Pattern matching rules
    12. Common typemap methods diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 8137bfcfe..226b4ef3e 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -22,13 +22,13 @@
    13. Typemap specifications -
    14. Pattern matching rules +
    15. Pattern matching rules
    16. Common typemap methods
        @@ -69,7 +74,7 @@
      • The run-time type checker
      • Typemaps and overloading
      • More about %apply and %clear @@ -655,7 +660,7 @@ of "The C Programming Language" by Kernighan and Ritchie or This section describes the behavior of the %typemap directive itself.

        -

        10.2.1 Defining a typemap

        +

        10.2.1 Defining a typemap

        @@ -988,7 +993,7 @@ It should be noted that for scoping to work, SWIG has to know that stringclass string.

        -

        10.3 Pattern matching rules

        +

        10.3 Pattern matching rules

        @@ -1646,6 +1651,7 @@ each type must have its own local variable declaration.

        Within all typemaps, the following special variables are expanded. +This is by no means a complete list as some target languages have additional special variables which are documented in the language specific chapters.

        @@ -1892,6 +1898,86 @@ Another approach, which only works for arrays is to use the $1_basetype +

        10.4.4 Special variable macros

        + + +

        +Special variable macros are like macro functions in that they take one or more input arguments +which are used for the macro expansion. +They look like macro/function calls but use the special variable $ prefix to the macro name. +Note that unlike normal macros, the expansion is not done by the preprocessor, +it is done during the SWIG parsing/compilation stages. +The following special variable macros are available across all language modules. +

        + +

        10.4.4.1 $descriptor(type)

        + + +

        +This macro expands into the type descriptor structure for any C/C++ type specified in type. +It behaves like the $1_descriptor special variable described above except that the type to expand is +taken from the macro argument rather than inferred from the typemap type. +For example, $descriptor(std::vector<int> *) will expand into SWIGTYPE_p_std__vectorT_int_t. +This macro is mostly used in the scripting target languages and is demonstrated later in the Run-time type checker usage section. +

        + +

        10.4.4.2 $typemap(method, typepattern)

        + + +

        +This macro uses the pattern matching rules described earlier to lookup and +then substitute the special variable macro with the code in the matched typemap. +The typemap to search for is specified by the arguments, where method is the typemap method name and +typepattern is a type pattern as per the %typemap specification in the Defining a typemap section. +

        + +

        +The special variables within the matched typemap are expanded into those for the matched typemap type, +not the typemap within which the macro is called. +In practice, there is little use for this macro in the scripting target languages. +It is mostly used in the target languages that are statically typed as a way to obtain the target language type given the C/C++ type and more commonly only when the C++ type is a template parameter. +

        + +

        +The example below is for C# only and uses some typemap method names documented in the C# chapter, but it shows some of the possible syntax variations. +

        + +
        +
        +%typemap(cstype) unsigned long    "uint"
        +%typemap(cstype) unsigned long bb "bool"
        +%typemap(cscode) BarClass %{
        +  void foo($typemap(cstype, unsigned long aa) var1,
        +           $typemap(cstype, unsigned long bb) var2,
        +           $typemap(cstype, (unsigned long bb)) var3,
        +           $typemap(cstype, unsigned long) var4)
        +  {
        +    // do something
        +  }
        +%}
        +
        +
        + +

        +The result is the following expansion +

        + +
        +
        +%typemap(cstype) unsigned long    "uint"
        +%typemap(cstype) unsigned long bb "bool"
        +%typemap(cscode) BarClass %{
        +  void foo(uint var1,
        +           bool var2,
        +           bool var3,
        +           uint var4)
        +  {
        +    // do something
        +  }
        +%}
        +
        +
        +

        10.5 Common typemap methods

        @@ -3295,7 +3381,7 @@ structures rather than creating new ones. These swig_module_info structures are chained together in a circularly linked list.

        -

        10.10.2 Usage

        +

        10.10.2 Usage

        This section covers how to use these functions from typemaps. To learn how to @@ -3335,8 +3421,8 @@ type tables and improves efficiency.

        Occasionally, you might need to write a typemap that needs to convert -pointers of other types. To handle this, a special macro substitution -$descriptor(type) can be used to generate the SWIG type +pointers of other types. To handle this, the special variable macro +$descriptor(type) covered earlier can be used to generate the SWIG type descriptor name for any C datatype. For example:

        diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index ec52f29e3..96c7526b8 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -292,6 +292,7 @@ CPP_TEST_CASES += \ smart_pointer_templatevariables \ smart_pointer_typedef \ special_variables \ + special_variable_functions \ static_array_member \ static_const_member \ static_const_member_2 \ diff --git a/Examples/test-suite/csharp/special_variable_functions_runme.cs b/Examples/test-suite/csharp/special_variable_functions_runme.cs new file mode 100644 index 000000000..02d4995d2 --- /dev/null +++ b/Examples/test-suite/csharp/special_variable_functions_runme.cs @@ -0,0 +1,18 @@ +using System; +using special_variable_functionsNamespace; + +public class runme { + static void Main() { + Name name = new Name(); + if (special_variable_functions.testFred(name) != "none") + throw new Exception("test failed"); + if (special_variable_functions.testJack(name) != "$specialname") + throw new Exception("test failed"); + if (special_variable_functions.testJill(name) != "jilly") + throw new Exception("test failed"); + if (special_variable_functions.testMary(name) != "SWIGTYPE_p_NameWrap") + throw new Exception("test failed"); + NewName newName = NewName.factory("factoryname"); + name = newName.getStoredName(); + } +} diff --git a/Examples/test-suite/csharp_prepost.i b/Examples/test-suite/csharp_prepost.i index 0c35c1833..817f5b9b9 100644 --- a/Examples/test-suite/csharp_prepost.i +++ b/Examples/test-suite/csharp_prepost.i @@ -25,7 +25,10 @@ "$csclassname.getCPtr(d$csinput)" // post only in csin typemap -%typemap(csin, post=" int size = $csinput.Count;\n for (int i=0; i &vpost +%typemap(csin, post=" int size = $csinput.Count;\n" + " for (int i=0; i &vpost "$csclassname.getCPtr($csinput)" %inline %{ diff --git a/Examples/test-suite/java/special_variable_functions_runme.java b/Examples/test-suite/java/special_variable_functions_runme.java new file mode 100644 index 000000000..b4d259932 --- /dev/null +++ b/Examples/test-suite/java/special_variable_functions_runme.java @@ -0,0 +1,28 @@ + +import special_variable_functions.*; + +public class special_variable_functions_runme { + + static { + try { + System.loadLibrary("special_variable_functions"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library 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_functions.testFred(name).equals("none")) + throw new RuntimeException("test failed"); + if (!special_variable_functions.testJack(name).equals("$specialname")) + throw new RuntimeException("test failed"); + if (!special_variable_functions.testJill(name).equals("jilly")) + throw new RuntimeException("test failed"); + if (!special_variable_functions.testMary(name).equals("SWIGTYPE_p_NameWrap")) + throw new RuntimeException("test failed"); + NewName newName = NewName.factory("factoryname"); + name = newName.getStoredName(); + } +} diff --git a/Examples/test-suite/python/special_variable_functions_runme.py b/Examples/test-suite/python/special_variable_functions_runme.py new file mode 100644 index 000000000..9473880b8 --- /dev/null +++ b/Examples/test-suite/python/special_variable_functions_runme.py @@ -0,0 +1,12 @@ +import special_variable_functions + +name = special_variable_functions.Name() +if special_variable_functions.testFred(name) != "none": + raise "test failed" +if special_variable_functions.testJack(name) != "$specialname": + raise "test failed" +if special_variable_functions.testJill(name) != "jilly": + raise "test failed" +if special_variable_functions.testMary(name) != "SWIGTYPE_p_NameWrap": + raise "test failed" + diff --git a/Examples/test-suite/special_variable_functions.i b/Examples/test-suite/special_variable_functions.i new file mode 100644 index 000000000..b0c39d73c --- /dev/null +++ b/Examples/test-suite/special_variable_functions.i @@ -0,0 +1,121 @@ +%module special_variable_functions + +// 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 +#warning TODO!!! + + +////////////////////////////////////////////////////////////////////////////////////// +// 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/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 9154f959a..cb7bb67a0 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -2766,6 +2766,16 @@ public: Delete(func_name); } + /*---------------------------------------------------------------------- + * replaceSpecialVariables() + *--------------------------------------------------------------------*/ + + virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) { + (void)method; + SwigType *type = Getattr(parm, "type"); + substituteClassname(type, tm); + } + /*---------------------------------------------------------------------- * decodeEnumFeature() * Decode the possible enum features, which are one of: @@ -2859,15 +2869,15 @@ public: /* ----------------------------------------------------------------------------- * substituteClassname() * - * Substitute $csclassname with the proxy class name for classes/structs/unions that SWIG knows about. - * Also substitutes enums with enum name. + * Substitute the special variable $csclassname with the proxy class name for classes/structs/unions + * that SWIG knows about. Also substitutes enums with enum name. * Otherwise use the $descriptor name for the C# class name. Note that the $&csclassname substitution * is the same as a $&descriptor substitution, ie one pointer added to descriptor name. * Inputs: * pt - parameter type - * tm - cstype typemap + * tm - typemap contents that might contain the special variable to be replaced * Outputs: - * tm - cstype typemap with $csclassname substitution + * tm - typemap contents complete with the special variable substitution * Return: * substitution_performed - flag indicating if a substitution was performed * ----------------------------------------------------------------------------- */ diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index ea24f34d1..ab84df3f7 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2603,6 +2603,16 @@ public: Delete(func_name); } + /*---------------------------------------------------------------------- + * replaceSpecialVariables() + *--------------------------------------------------------------------*/ + + virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) { + (void)method; + SwigType *type = Getattr(parm, "type"); + substituteClassname(type, tm); + } + /*---------------------------------------------------------------------- * decodeEnumFeature() * Decode the possible enum features, which are one of: @@ -2700,16 +2710,16 @@ public: /* ----------------------------------------------------------------------------- * substituteClassname() * - * Substitute $javaclassname with the proxy class name for classes/structs/unions that SWIG knows about. - * Also substitutes enums with enum name. + * Substitute the special variable $javaclassname with the proxy class name for classes/structs/unions + * that SWIG knows about. Also substitutes enums with enum name. * Otherwise use the $descriptor name for the Java class name. Note that the $&javaclassname substitution * is the same as a $&descriptor substitution, ie one pointer added to descriptor name. * Inputs: * pt - parameter type - * tm - jstype typemap + * tm - typemap contents that might contain the special variable to be replaced * jnidescriptor - if set, inner class names are separated with '$' otherwise a '.' * Outputs: - * tm - jstype typemap with $javaclassname substitution + * tm - typemap contents complete with the special variable substitution * Return: * substitution_performed - flag indicating if a substitution was performed * ----------------------------------------------------------------------------- */ diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 38658ce9c..36bbf5e9f 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -18,6 +18,7 @@ static int director_mode = 0; static int director_protected_mode = 1; static int all_protected_mode = 0; static int naturalvar_mode = 0; +Language* Language::this_ = 0; /* Set director_protected_mode */ void Wrapper_director_mode_set(int flag) { @@ -46,6 +47,9 @@ extern "C" { int Swig_all_protected_mode() { return all_protected_mode; } + void Language_replace_special_variables(String *method, String *tm, Parm *parm) { + Language::instance()->replaceSpecialVariables(method, tm, parm); + } } /* Some status variables used during parsing */ @@ -323,6 +327,8 @@ directors(0) { director_prot_ctor_code = 0; director_multiple_inheritance = 1; director_language = 0; + assert(!this_); + this_ = this; } Language::~Language() { @@ -331,6 +337,7 @@ Language::~Language() { Delete(enumtypes); Delete(director_ctor_code); Delete(none_comparison); + this_ = 0; } /* ---------------------------------------------------------------------- @@ -3423,6 +3430,24 @@ String *Language::defaultExternalRuntimeFilename() { return 0; } +/* ----------------------------------------------------------------------------- + * Language::replaceSpecialVariables() + * Language modules should implement this if special variables are to be handled + * correctly in the $typemap(...) special variable macro. + * method - typemap method name + * tm - string containing typemap contents + * parm - a parameter describing the typemap type to be handled + * ----------------------------------------------------------------------------- */ +void Language::replaceSpecialVariables(String *method, String *tm, Parm *parm) { + (void)method; + (void)tm; + (void)parm; +} + +Language *Language::instance() { + return this_; +} + Hash *Language::getClassHash() const { return classhash; } diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 5445d0761..be2765bc1 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -3581,17 +3581,28 @@ MODULA3(): Delete(throws_hash); } + /*---------------------------------------------------------------------- + * replaceSpecialVariables() + *--------------------------------------------------------------------*/ + + virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) { + (void)method; + SwigType *type = Getattr(parm, "type"); + substituteClassname(type, tm); + } + /* ----------------------------------------------------------------------------- * substituteClassname() * - * Substitute $m3classname with the proxy class name for classes/structs/unions that SWIG knows about. + * Substitute the special variable $m3classname with the proxy class name for classes/structs/unions + * that SWIG knows about. * Otherwise use the $descriptor name for the Modula 3 class name. Note that the $&m3classname substitution * is the same as a $&descriptor substitution, ie one pointer added to descriptor name. * Inputs: * pt - parameter type - * tm - m3wraptype typemap + * tm - typemap contents that might contain the special variable to be replaced * Outputs: - * tm - m3wraptype typemap with $m3classname substitution + * tm - typemap contents complete with the special variable substitution * Return: * substitution_performed - flag indicating if a substitution was performed * ----------------------------------------------------------------------------- */ diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 8dec8d0af..440e0e960 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -216,6 +216,7 @@ public: virtual int is_assignable(Node *n); /* Is variable assignable? */ virtual String *runtimeCode(); /* returns the language specific runtime code */ virtual String *defaultExternalRuntimeFilename(); /* the default filename for the external runtime */ + virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm); /* Language specific special variable substitutions for $typemap() */ /* Runtime is C++ based, so extern "C" header section */ void enable_cplus_runtime_mode(); @@ -250,6 +251,9 @@ public: /* Set overload variable templates argc and argv */ void setOverloadResolutionTemplates(String *argc, String *argv); + /* Language instance is a singleton - get instance */ + static Language* instance(); + protected: /* Allow multiple-input typemaps */ void allow_multiple_input(int val = 1); @@ -307,6 +311,7 @@ private: int multiinput; int cplus_runtime; int directors; + static Language *this_; }; int SWIG_main(int, char **, Language *); @@ -347,7 +352,9 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f); extern "C" { void SWIG_typemap_lang(const char *); typedef Language *(*ModuleFactory) (void); -} void Swig_register_module(const char *name, ModuleFactory fac); +} + +void Swig_register_module(const char *name, ModuleFactory fac); ModuleFactory Swig_find_module(const char *name); /* Utilities */ diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 53f1ad4a0..3de794fdc 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -85,6 +85,7 @@ void Scanner_clear(Scanner * s) { Clear(s->text); Clear(s->scanobjs); Delete(s->error); + s->str = 0; s->error = 0; s->line = 1; s->nexttoken = -1; diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 68e7d3a10..86b956399 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -390,6 +390,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Wrapper_director_mode_set(int); extern void Wrapper_director_protected_mode_set(int); extern void Wrapper_all_protected_mode_set(int); + extern void Language_replace_special_variables(String *method, String *tm, Parm *parm); /* -- template init -- */ diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index fd4e42579..3e1ffda49 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -17,7 +17,7 @@ char cvsroot_typemap_c[] = "$Id$"; #define SWIG_DEBUG #endif -static void replace_embedded_typemap(String *s); +static void replace_embedded_typemap(String *s, String *lname, Wrapper *f); /* ----------------------------------------------------------------------------- * Typemaps are stored in a collection of nested hash tables. Something like @@ -31,14 +31,24 @@ static void replace_embedded_typemap(String *s); * different typemap methods. These are referenced by names such as * "tmap:in", "tmap:out", "tmap:argout", and so forth. * - * The object corresponding to a specific method has the following - * attributes: + * The object corresponding to a specific typemap method has the following attributes: * * "type" - Typemap type * "pname" - Parameter name * "code" - Typemap code * "typemap" - Descriptive text describing the actual map * "locals" - Local variables (if any) + * "kwargs" - Typemap attributes + * + * Example for a typemap method named "in": + * %typemap(in, warning="987:my warning", noblock=1) int &my_int (int tmp) "$1 = $input;" + * + * "type" - r.int + * "pname" - my_int + * "code" - $1 = $input; + * "typemap" - typemap(in) int &my_int + * "locals" - int tmp + * "kwargs" - warning="987:my typemap warning", foo=123 * * ----------------------------------------------------------------------------- */ @@ -163,7 +173,7 @@ Hash *Swig_typemap_pop_scope() { /* ----------------------------------------------------------------------------- * Swig_typemap_register() * - * Add a new multi-valued typemap + * Add a new multi-argument typemap * ----------------------------------------------------------------------------- */ void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) { @@ -210,7 +220,7 @@ void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_S Delete(tm2); } - /* For a multi-valued typemap, the typemap code and information + /* For a multi-argument typemap, the typemap code and information is really only stored in the last argument. However, to make this work, we perform a really neat trick using the typemap operator name. @@ -346,7 +356,7 @@ int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList /* ----------------------------------------------------------------------------- * Swig_typemap_clear() * - * Delete a multi-valued typemap + * Delete a multi-argument typemap * ----------------------------------------------------------------------------- */ void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) { @@ -735,7 +745,7 @@ ret_result: /* ----------------------------------------------------------------------------- * typemap_search_multi() * - * Search for a multi-valued typemap. + * Search for a multi-argument typemap. * ----------------------------------------------------------------------------- */ static Hash *typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch) { @@ -806,7 +816,7 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi SwigType *ftype; int bare_substitution_count = 0; - Replaceall(s, "$typemap", "$TYPEMAP"); + Replaceall(s, "$typemap", "$TYPEMAP"); /* workaround for $type substitution below */ ftype = SwigType_typedef_resolve_all(type); @@ -1162,8 +1172,18 @@ static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) { * * Attach one or more typemaps to a node and optionally generate the typemap contents * into the wrapper. - * op - typemap name, eg "out", "newfree" - * node - the node to attach the typemaps to + * + * Looks for a typemap matching the given type and name and attaches the typemap code + * and any typemap attributes to the provided node. + * + * The node should contain the "type" and "name" attributes for the typemap match on. + * input. The typemap code and typemap attribute values are attached onto the node + * prefixed with "tmap:". For example with op="in", the typemap code can be retrieved + * with a call to Getattr(node, "tmap:in") (this is also the string returned) and the + * "noblock" attribute can be retrieved with a call to Getattr(node, "tmap:in:noblock"). + * + * op - typemap method, eg "in", "out", "newfree" + * node - the node to attach the typemap and typemap attributes to * lname - name of variable to substitute $1, $2 etc for * f - wrapper code to generate into if non null * actioncode - code to generate into f before the out typemap code, unless @@ -1242,10 +1262,10 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, kw = Getattr(tm, "kwargs"); while (kw) { String *value = Copy(Getattr(kw, "value")); - String *type = Getattr(kw, "type"); + String *kwtype = Getattr(kw, "type"); char *ckwname = Char(Getattr(kw, "name")); - if (type) { - String *mangle = Swig_string_mangle(type); + if (kwtype) { + String *mangle = Swig_string_mangle(kwtype); Append(value, mangle); Delete(mangle); } @@ -1324,7 +1344,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, if (locals && f) { typemap_locals(s, locals, f, -1); } - replace_embedded_typemap(s); + replace_embedded_typemap(s, NewString(lname), f); Replace(s, "$name", pname, DOH_REPLACE_ANY); @@ -1357,11 +1377,11 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, /* Look for code fragments */ { - String *f; + String *fragment; sprintf(temp, "%s:fragment", cop); - f = Getattr(node, tmop_name(temp)); - if (f) { - String *fname = Copy(f); + fragment = Getattr(node, tmop_name(temp)); + if (fragment) { + String *fname = Copy(fragment); Setfile(fname, Getfile(node)); Setline(fname, Getline(node)); Swig_fragment_emit(fname); @@ -1457,13 +1477,6 @@ static void typemap_emit_code_fragments(const_String_or_char_ptr op, Parm *p) { Delete(temp); } -/* ----------------------------------------------------------------------------- - * Swig_typemap_attach_parms() - * - * Given a parameter list, this function attaches all of the typemaps for a - * given typemap type - * ----------------------------------------------------------------------------- */ - static String *typemap_get_option(Hash *tm, const_String_or_char_ptr name) { Parm *kw = Getattr(tm, "kwargs"); while (kw) { @@ -1476,6 +1489,22 @@ static String *typemap_get_option(Hash *tm, const_String_or_char_ptr name) { return 0; } +/* ----------------------------------------------------------------------------- + * Swig_typemap_attach_parms() + * + * Given a parameter list, this function attaches all of the typemaps and typemap + * attributes to the parameter for each type in the parameter list. + * + * This function basically provides the typemap code and typemap attribute values as + * attributes on each parameter prefixed with "tmap:". For example with op="in", the typemap + * code can be retrieved for the first parameter with a call to Getattr(parm, "tmap:in") + * and the "numinputs" attribute can be retrieved with a call to Getattr(parm, "tmap:in:numinputs"). + * + * op - typemap method, eg "in", "out", "newfree" + * parms - parameter list to attach each typemap and all typemap attributes + * f - wrapper code to generate into if non null + * ----------------------------------------------------------------------------- */ + void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f) { Parm *p, *firstp; Hash *tm; @@ -1614,7 +1643,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra typemap_locals(s, locals, f, argnum); } - replace_embedded_typemap(s); + replace_embedded_typemap(s, Getattr(firstp, "lname"), f); /* Replace the argument number */ sprintf(temp, "%d", argnum); @@ -1659,23 +1688,8 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra } -/* ----------------------------------------------------------------------------- - * split_embedded() - * - * This function replaces the special variable $typemap(....) with typemap - * code. The general form of $typemap is as follows: - * - * $TYPEMAP(method, $var1=value, $var2=value, $var3=value,...) - * - * For example: - * - * $TYPEMAP(in, $1=int x, $input=y, ...) - * - * Note: this was added as an experiment and could be removed - * ----------------------------------------------------------------------------- */ - /* Splits the arguments of an embedded typemap */ -static List *split_embedded(String *s) { +static List *split_embedded_typemap(String *s) { List *args = 0; char *c, *start; int level = 0; @@ -1683,6 +1697,7 @@ static List *split_embedded(String *s) { args = NewList(); c = strchr(Char(s), '('); + assert(c); c++; start = c; @@ -1723,41 +1738,36 @@ static List *split_embedded(String *s) { return args; } -static void split_var(String *s, String **name, String **value) { - char *eq; - char *c; +/* ----------------------------------------------------------------------------- + * replace_embedded_typemap() + * + * This function replaces the special variable macro $typemap(...) with typemap + * code. The general form of $typemap is as follows: + * + * $typemap(method, typelist, var1=value, var2=value, ...) + * + * where varx parameters are optional and undocumented; they were used in an earlier version of $typemap. + * A search is made using the typemap matching rules of form: + * + * %typemap(method) typelist {...} + * + * and if found will substitute in the typemap contents, making appropriate variable replacements. + * + * For example: + * $typemap(in, int) # simple usage matching %typemap(in) int { ... } + * $typemap(in, int b) # simple usage matching %typemap(in) int b { ... } or above %typemap + * $typemap(in, (Foo a, int b)) # multi-argument typemap matching %typemap(in) (Foo a, int b) {...} + * ----------------------------------------------------------------------------- */ - eq = strchr(Char(s), '='); - if (!eq) { - *name = 0; - *value = 0; - return; - } - c = Char(s); - *name = NewStringWithSize(c, eq - c); - - /* Look for $n variables */ - if (isdigit((int) *(c))) { - /* Parse the value as a type */ - String *v; - Parm *p; - v = NewString(eq + 1); - p = Swig_cparse_parm(v); - Delete(v); - *value = p; - } else { - *value = NewString(eq + 1); - } -} - -static void replace_embedded_typemap(String *s) { +static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) { char *start = 0; - while ((start = strstr(Char(s), "$TYPEMAP("))) { + while ((start = strstr(Char(s), "$TYPEMAP("))) { /* note $typemap capitalisation to $TYPEMAP hack */ - /* Gather the argument */ + /* Gather the parameters */ char *end = 0, *c; int level = 0; - String *tmp; + String *dollar_typemap; + int syntax_error = 1; c = start; while (*c) { if (*c == '(') @@ -1772,103 +1782,119 @@ static void replace_embedded_typemap(String *s) { c++; } if (end) { - tmp = NewStringWithSize(start, (end - start)); + dollar_typemap = NewStringWithSize(start, (end - start)); + syntax_error = 0; } else { - tmp = 0; + dollar_typemap = NewStringWithSize(start, (c - start)); } - /* Got a substitution. Split it apart into pieces */ - if (tmp) { + if (!syntax_error) { List *l; + String *op; Hash *vars; - String *method; - int i, ilen; + syntax_error = 1; - l = split_embedded(tmp); - vars = NewHash(); - ilen = Len(l); - for (i = 1; i < ilen; i++) { - String *n, *v; - split_var(Getitem(l, i), &n, &v); - if (n && v) { - Insert(n, 0, "$"); - Setattr(vars, n, v); - } - Delete(n); - Delete(v); - } + /* Split apart each parameter in $typemap(...) */ + l = split_embedded_typemap(dollar_typemap); - method = Getitem(l, 0); - /* Generate the parameter list for matching typemaps */ + if (Len(l) >= 2) { + ParmList *to_match_parms; + op = Getitem(l, 0); - { - Parm *p = 0; - Parm *first = 0; - char temp[32]; - int n = 1; - while (1) { - Hash *v; - sprintf(temp, "$%d", n); - v = Getattr(vars, temp); - if (v) { - if (p) { - set_nextSibling(p, v); - set_previousSibling(v, p); - } - p = v; - Setattr(p, "lname", Getattr(p, "name")); - if (Getattr(p, "value")) { - Setattr(p, "name", Getattr(p, "value")); - } - if (!first) - first = p; - DohIncref(p); - Delattr(vars, temp); - } else { - break; + /* the second parameter might contain multiple sub-parameters for multi-argument + * typemap matching, so split these parameters apart */ + to_match_parms = Swig_cparse_parms(Getitem(l, 1)); + if (to_match_parms) { + Parm *p = to_match_parms;; + while (p) { + Setattr(p, "lname", lname); + p = nextSibling(p); } - n++; } + + /* process optional extra parameters - the variable replacements (undocumented) */ + vars = NewHash(); + { + int i, ilen; + ilen = Len(l); + for (i = 2; i < ilen; i++) { + String *parm = Getitem(l, i); + char *eq = strchr(Char(parm), '='); + char *c = Char(parm); + if (eq && (eq - c > 0)) { + String *name = NewStringWithSize(c, eq - c); + String *value = NewString(eq + 1); + Insert(name, 0, "$"); + Setattr(vars, name, value); + } else { + to_match_parms = 0; /* error - variable replacement parameters must be of form varname=value */ + } + } + } + /* Perform a typemap search */ - if (first) { + if (to_match_parms) { + static int already_substituting = 0; + String *tm; + String *attr; + int match = 0; #ifdef SWIG_DEBUG Printf(stdout, "Swig_typemap_attach_parms: embedded\n"); #endif - Swig_typemap_attach_parms(method, first, 0); - { - String *tm; - int match = 0; - char attr[64]; - sprintf(attr, "tmap:%s", Char(method)); + if (!already_substituting) { + already_substituting = 1; + Swig_typemap_attach_parms(op, to_match_parms, f); + already_substituting = 0; /* Look for the typemap code */ - tm = Getattr(first, attr); + attr = NewStringf("tmap:%s", op); + tm = Getattr(to_match_parms, attr); if (tm) { - sprintf(attr, "tmap:%s:next", Char(method)); - if (!Getattr(first, attr)) { - /* Should be no more matches. Hack??? */ - /* Replace all of the remaining variables */ + Printf(attr, "%s", ":next"); + /* fail if multi-argument lookup requested in $typemap(...) and the lookup failed */ + if (!Getattr(to_match_parms, attr)) { + /* Replace parameter variables */ Iterator ki; for (ki = First(vars); ki.key; ki = Next(ki)) { Replace(tm, ki.key, ki.item, DOH_REPLACE_ANY); } - /* Do the replacement */ - Replace(s, tmp, tm, DOH_REPLACE_ANY); + /* offer the target language module the chance to make special variable substitutions */ + Language_replace_special_variables(op, tm, to_match_parms); + /* finish up - do the substitution */ + Replace(s, dollar_typemap, tm, DOH_REPLACE_ANY); Delete(tm); match = 1; } } + if (!match) { - Swig_error(Getfile(s), Getline(s), "No typemap found for %s\n", tmp); + String *dtypemap = NewString(dollar_typemap); + Replaceall(dtypemap, "$TYPEMAP", "$typemap"); + Swig_error(Getfile(s), Getline(s), "No typemap found for %s\n", dtypemap); + Delete(dtypemap); } + Delete(attr); + } else { + /* simple recursive call check, but prevents using an embedded typemap that contains another embedded typemap */ + String *dtypemap = NewString(dollar_typemap); + Replaceall(dtypemap, "$TYPEMAP", "$typemap"); + Swig_error(Getfile(s), Getline(s), "Recursive $typemap calls not supported - %s\n", dtypemap); + Delete(dtypemap); } + syntax_error = 0; } + Delete(vars); } - Replace(s, tmp, "", DOH_REPLACE_ANY); - Delete(vars); - Delete(tmp); Delete(l); } + if (syntax_error) { + String *dtypemap = NewString(dollar_typemap); + Replaceall(dtypemap, "$TYPEMAP", "$typemap"); + Swig_error(Getfile(s), Getline(s), "Syntax error in: %s\n", dtypemap); + Delete(dtypemap); + } + Replace(s, dollar_typemap, "", DOH_REPLACE_ANY); + Delete(dollar_typemap); } } From b1a1e3d3235a2c551fa4baa92ad1aa41b0210174 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 29 Jul 2009 20:52:29 +0000 Subject: [PATCH 062/352] consistent terminology for multi-argument typemaps git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11471 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/allegrocl.cxx | 2 +- Source/Modules/emit.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 1cccca69f..2f1b07296 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -2006,7 +2006,7 @@ Node *parent_node_skipping_extends(Node *n) { * emit_num_lin_arguments() * * Calculate the total number of arguments. This function is safe for use - * with multi-valued typemaps which may change the number of arguments in + * with multi-argument typemaps which may change the number of arguments in * strange ways. * ----------------------------------------------------------------------------- */ diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx index a4cf8cebc..017f492db 100644 --- a/Source/Modules/emit.cxx +++ b/Source/Modules/emit.cxx @@ -200,7 +200,7 @@ void emit_attach_parmmaps(ParmList *l, Wrapper *f) { * emit_num_arguments() * * Calculate the total number of arguments. This function is safe for use - * with multi-valued typemaps which may change the number of arguments in + * with multi-argument typemaps which may change the number of arguments in * strange ways. * ----------------------------------------------------------------------------- */ @@ -232,7 +232,7 @@ int emit_num_arguments(ParmList *parms) { * emit_num_required() * * Computes the number of required arguments. This function is safe for - * use with multi-valued typemaps and knows how to skip over everything + * use with multi-argument typemaps and knows how to skip over everything * properly. Note that parameters with default values are counted unless * the compact default args option is on. * ----------------------------------------------------------------------------- */ From 9cd5c28d73f4641c6ff329f7a567822ba926d919 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 29 Jul 2009 21:01:28 +0000 Subject: [PATCH 063/352] section numbering update git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11472 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 16 +++++++++++++--- Doc/Manual/Tcl.html | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index ee19f9b73..0e7ebf464 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1120,7 +1120,7 @@
      • Modules and packages
    17. Input and output parameters -
    18. Exception handling +
    19. Exception handling
    20. Remapping datatypes with typemaps
    21. Typemap Examples
    22. PHP Pragmas, Startup and Shutdown code +
    23. Cross language polymorphism + diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index 2c02a9b34..8b8c74dc0 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -3412,6 +3412,7 @@ interesting things.

      33.10 Tcl/Tk Stubs

      +

      For background information about the Tcl Stubs feature, see http://www.tcl.tk/doc/howto/stubs.html. From 7f0e632dddf3ba88841f137959c2bf7c119da81f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Jul 2009 06:06:49 +0000 Subject: [PATCH 064/352] typemap method name: use consistent terminology in code git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11473 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 20 ++-- Source/Modules/csharp.cxx | 8 +- Source/Modules/java.cxx | 8 +- Source/Modules/modula3.cxx | 8 +- Source/Modules/php.cxx | 4 +- Source/Swig/swig.h | 12 +-- Source/Swig/typemap.c | 194 ++++++++++++++++++------------------- 7 files changed, 127 insertions(+), 127 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 11232fd78..a4787bf4a 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1465,7 +1465,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { } decl; Parm *tparms; struct { - String *op; + String *method; Hash *kwargs; } tmap; struct { @@ -2499,10 +2499,10 @@ varargs_parms : parms { $$ = $1; } typemap_directive : TYPEMAP LPAREN typemap_type RPAREN tm_list stringbrace { $$ = 0; - if ($3.op) { + if ($3.method) { String *code = 0; $$ = new_node("typemap"); - Setattr($$,"method",$3.op); + Setattr($$,"method",$3.method); if ($3.kwargs) { ParmList *kw = $3.kwargs; code = remove_block(kw, $6); @@ -2516,17 +2516,17 @@ typemap_directive : TYPEMAP LPAREN typemap_type RPAREN tm_list stringbrace { } | TYPEMAP LPAREN typemap_type RPAREN tm_list SEMI { $$ = 0; - if ($3.op) { + if ($3.method) { $$ = new_node("typemap"); - Setattr($$,"method",$3.op); + Setattr($$,"method",$3.method); appendChild($$,$5); } } | TYPEMAP LPAREN typemap_type RPAREN tm_list EQUAL typemap_parm SEMI { $$ = 0; - if ($3.op) { + if ($3.method) { $$ = new_node("typemapcopy"); - Setattr($$,"method",$3.op); + Setattr($$,"method",$3.method); Setattr($$,"pattern", Getattr($7,"pattern")); appendChild($$,$5); } @@ -2546,15 +2546,15 @@ typemap_type : kwargs { /* two argument typemap form */ name = Getattr($1,"name"); if (!name || (Strcmp(name,typemap_lang))) { - $$.op = 0; + $$.method = 0; $$.kwargs = 0; } else { - $$.op = Getattr(p,"name"); + $$.method = Getattr(p,"name"); $$.kwargs = nextSibling(p); } } else { /* one-argument typemap-form */ - $$.op = Getattr($1,"name"); + $$.method = Getattr($1,"name"); $$.kwargs = p; } } diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index cb7bb67a0..fa76e42c8 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3039,7 +3039,7 @@ public: /* ----------------------------------------------------------------------------- * typemapLookup() * n - for input only and must contain info for Getfile(n) and Getline(n) to work - * op - typemap method name + * tmap_method - typemap method name * type - typemap type to lookup * warning - warning number to issue if no typemaps found * typemap_attributes - the typemap attributes are attached to this node and will @@ -3047,16 +3047,16 @@ public: * return is never NULL, unlike Swig_typemap_lookup() * ----------------------------------------------------------------------------- */ - const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) { + const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) { Node *node = !typemap_attributes ? NewHash() : typemap_attributes; Setattr(node, "type", type); Setfile(node, Getfile(n)); Setline(node, Getline(n)); - const String *tm = Swig_typemap_lookup(op, node, "", 0); + const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0); if (!tm) { tm = empty_string; if (warning != WARN_NONE) - Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0)); + Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0)); } if (!typemap_attributes) Delete(node); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index ab84df3f7..7ed4df636 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -2872,7 +2872,7 @@ public: /* ----------------------------------------------------------------------------- * typemapLookup() * n - for input only and must contain info for Getfile(n) and Getline(n) to work - * op - typemap method name + * tmap_method - typemap method name * type - typemap type to lookup * warning - warning number to issue if no typemaps found * typemap_attributes - the typemap attributes are attached to this node and will @@ -2880,16 +2880,16 @@ public: * return is never NULL, unlike Swig_typemap_lookup() * ----------------------------------------------------------------------------- */ - const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) { + const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) { Node *node = !typemap_attributes ? NewHash() : typemap_attributes; Setattr(node, "type", type); Setfile(node, Getfile(n)); Setline(node, Getline(n)); - const String *tm = Swig_typemap_lookup(op, node, "", 0); + const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0); if (!tm) { tm = empty_string; if (warning != WARN_NONE) - Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0)); + Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0)); } if (!typemap_attributes) Delete(node); diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index be2765bc1..b9eb840f6 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -3818,7 +3818,7 @@ MODULA3(): /* ----------------------------------------------------------------------------- * typemapLookup() * n - for input only and must contain info for Getfile(n) and Getline(n) to work - * op - typemap method name + * tmap_method - typemap method name * type - typemap type to lookup * warning - warning number to issue if no typemaps found * typemap_attributes - the typemap attributes are attached to this node and will @@ -3826,16 +3826,16 @@ MODULA3(): * return is never NULL, unlike Swig_typemap_lookup() * ----------------------------------------------------------------------------- */ - const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) { + const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) { Node *node = !typemap_attributes ? NewHash() : typemap_attributes; Setattr(node, "type", type); Setfile(node, Getfile(n)); Setline(node, Getline(n)); - const String *tm = Swig_typemap_lookup(op, node, "", 0); + const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0); if (!tm) { tm = empty_string; if (warning != WARN_NONE) - Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0)); + Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0)); } if (!typemap_attributes) Delete(node); diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index d64c04131..8f5178c36 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2196,8 +2196,8 @@ public: return NewStringEmpty(); } - String *PhpTypeFromTypemap(char *op, Node *n, const_String_or_char_ptr lname) { - String *tms = Swig_typemap_lookup(op, n, lname, 0); + String *PhpTypeFromTypemap(char *tmap_method, Node *n, const_String_or_char_ptr lname) { + String *tms = Swig_typemap_lookup(tmap_method, n, lname, 0); if (!tms) return 0; else diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 86b956399..a5f13bd77 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -363,19 +363,19 @@ extern int ParmList_is_compactdefargs(ParmList *p); /* --- Legacy Typemap API (somewhat simplified, ha!) --- */ extern void Swig_typemap_init(void); - extern void Swig_typemap_register(const_String_or_char_ptr op, ParmList *pattern, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs); - extern int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcpattern, ParmList *pattern); - extern void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *pattern); + extern void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *pattern, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs); + extern int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcpattern, ParmList *pattern); + extern void Swig_typemap_clear(const_String_or_char_ptr tmap_method, ParmList *pattern); extern int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat); extern void Swig_typemap_clear_apply(ParmList *pattern); extern void Swig_typemap_debug(void); - extern String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f); - extern String *Swig_typemap_lookup_out(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode); + extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f); + extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode); extern void Swig_typemap_new_scope(void); extern Hash *Swig_typemap_pop_scope(void); - extern void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f); + extern void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *parms, Wrapper *f); /* --- Code fragment support --- */ diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 3e1ffda49..3392fd64c 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -117,29 +117,29 @@ void Swig_typemap_init() { tm_scope = 0; } -static String *tmop_name(const_String_or_char_ptr op) { +static String *typemap_method_name(const_String_or_char_ptr tmap_method) { static Hash *names = 0; String *s; /* Due to "interesting" object-identity semantics of DOH, we have to make sure that we only intern strings without object identity into the hash table. - (typemap_attach_kwargs calls tmop_name several times with - the "same" String *op (i.e., same object identity) but differing + (typemap_attach_kwargs calls typemap_method_name several times with + the "same" String *tmap_method (i.e., same object identity) but differing string values.) Most other callers work around this by using char* rather than String *. -- mkoeppe, Jun 17, 2003 */ - const char *op_without_object_identity = Char(op); + const char *method_without_object_identity = Char(tmap_method); if (!names) names = NewHash(); - s = Getattr(names, op_without_object_identity); + s = Getattr(names, method_without_object_identity); if (s) return s; - s = NewStringf("tmap:%s", op); - Setattr(names, op_without_object_identity, s); + s = NewStringf("tmap:%s", tmap_method); + Setattr(names, method_without_object_identity, s); Delete(s); return s; } @@ -176,18 +176,18 @@ Hash *Swig_typemap_pop_scope() { * Add a new multi-argument typemap * ----------------------------------------------------------------------------- */ -void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) { +void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) { Hash *tm; Hash *tm1; Hash *tm2; Parm *np; - String *tmop; + String *tm_method; SwigType *type; String *pname; if (!parms) return; - tmop = tmop_name(op); + tm_method = typemap_method_name(tmap_method); /* Register the first type in the parameter list */ @@ -212,11 +212,11 @@ void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_S tm = tm1; } - /* Now see if this typemap op has been seen before */ - tm2 = Getattr(tm, tmop); + /* Now see if this typemap method has been seen before */ + tm2 = Getattr(tm, tm_method); if (!tm2) { tm2 = NewHash(); - Setattr(tm, tmop, tm2); + Setattr(tm, tm_method, tm2); Delete(tm2); } @@ -247,7 +247,7 @@ void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_S np = nextSibling(parms); if (np) { /* Make an entirely new operator key */ - String *newop = NewStringf("%s-%s+%s:", op, type, pname); + String *newop = NewStringf("%s-%s+%s:", tmap_method, type, pname); /* Now reregister on the remaining arguments */ Swig_typemap_register(newop, np, code, locals, kwargs); @@ -255,7 +255,7 @@ void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_S Delete(newop); } else { String *str = SwigType_str(type, pname); - String *typemap = NewStringf("typemap(%s) %s", op, str); + String *typemap = NewStringf("typemap(%s) %s", tmap_method, str); ParmList *clocals = CopyParmList(locals); ParmList *ckwargs = CopyParmList(kwargs); @@ -304,21 +304,21 @@ static Hash *typemap_get(SwigType *type, const_String_or_char_ptr name, int scop * Copy a typemap * ----------------------------------------------------------------------------- */ -int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList *parms) { +int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcparms, ParmList *parms) { Hash *tm = 0; - String *tmop; + String *tm_method; Parm *p; String *pname; SwigType *ptype; int ts = tm_scope; - String *tmops, *newop; + String *tm_methods, *newop; if (ParmList_len(parms) != ParmList_len(srcparms)) return -1; - tmop = tmop_name(op); + tm_method = typemap_method_name(tmap_method); while (ts >= 0) { p = srcparms; - tmops = NewString(tmop); + tm_methods = NewString(tm_method); while (p) { ptype = Getattr(p, "type"); pname = Getattr(p, "name"); @@ -328,22 +328,22 @@ int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList if (!tm) break; - tm = Getattr(tm, tmops); + tm = Getattr(tm, tm_methods); if (!tm) break; /* Got a match. Look for next typemap */ - newop = NewStringf("%s-%s+%s:", tmops, ptype, pname); - Delete(tmops); - tmops = newop; + newop = NewStringf("%s-%s+%s:", tm_methods, ptype, pname); + Delete(tm_methods); + tm_methods = newop; p = nextSibling(p); } - Delete(tmops); + Delete(tm_methods); if (!p && tm) { /* Got some kind of match */ - Swig_typemap_register(op, parms, Getattr(tm, "code"), Getattr(tm, "locals"), Getattr(tm, "kwargs")); + Swig_typemap_register(tmap_method, parms, Getattr(tm, "code"), Getattr(tm, "locals"), Getattr(tm, "kwargs")); return 0; } ts--; @@ -359,7 +359,7 @@ int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList * Delete a multi-argument typemap * ----------------------------------------------------------------------------- */ -void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) { +void Swig_typemap_clear(const_String_or_char_ptr tmap_method, ParmList *parms) { SwigType *type; String *name; Parm *p; @@ -367,7 +367,7 @@ void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) { Hash *tm = 0; /* This might not work */ - newop = NewString(op); + newop = NewString(tmap_method); p = parms; while (p) { type = Getattr(p, "type"); @@ -380,7 +380,7 @@ void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) { Printf(newop, "-%s+%s:", type, name); } if (tm) { - tm = Getattr(tm, tmop_name(newop)); + tm = Getattr(tm, typemap_method_name(newop)); if (tm) { Delattr(tm, "code"); Delattr(tm, "locals"); @@ -601,7 +601,7 @@ static SwigType *strip_arrays(SwigType *type) { * that includes a 'code' attribute. * ----------------------------------------------------------------------------- */ -static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr name, SwigType **matchtype) { +static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type, const_String_or_char_ptr name, SwigType **matchtype) { Hash *result = 0, *tm, *tm1, *tma; Hash *backup = 0; SwigType *noarrays = 0; @@ -611,7 +611,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S int isarray; const String *cname = 0; SwigType *unstripped = 0; - String *tmop = tmop_name(op); + String *tm_method = typemap_method_name(tmap_method); if ((name) && Len(name)) cname = name; @@ -625,7 +625,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S if (tm && cname) { tm1 = Getattr(tm, cname); if (tm1) { - result = Getattr(tm1, tmop); /* See if there is a type-name match */ + result = Getattr(tm1, tm_method); /* See if there is a type-name match */ if (result && Getattr(result, "code")) goto ret_result; if (result) @@ -633,7 +633,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S } } if (tm) { - result = Getattr(tm, tmop); /* See if there is simply a type match */ + result = Getattr(tm, tm_method); /* See if there is simply a type match */ if (result && Getattr(result, "code")) goto ret_result; if (result) @@ -650,7 +650,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S if (tma && cname) { tm1 = Getattr(tma, cname); if (tm1) { - result = Getattr(tm1, tmop); /* type-name match */ + result = Getattr(tm1, tm_method); /* type-name match */ if (result && Getattr(result, "code")) goto ret_result; if (result) @@ -658,7 +658,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S } } if (tma) { - result = Getattr(tma, tmop); /* type match */ + result = Getattr(tma, tm_method); /* type match */ if (result && Getattr(result, "code")) goto ret_result; if (result) @@ -702,13 +702,13 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S if (tm && cname) { tm1 = Getattr(tm, cname); if (tm1) { - result = Getattr(tm1, tmop); /* See if there is a type-name match */ + result = Getattr(tm1, tm_method); /* See if there is a type-name match */ if (result) goto ret_result; } } if (tm) { /* See if there is simply a type match */ - result = Getattr(tm, tmop); + result = Getattr(tm, tm_method); if (result) goto ret_result; } @@ -748,7 +748,7 @@ ret_result: * Search for a multi-argument typemap. * ----------------------------------------------------------------------------- */ -static Hash *typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch) { +static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList *parms, int *nmatch) { SwigType *type; SwigType *mtype = 0; String *name; @@ -763,13 +763,13 @@ static Hash *typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, name = Getattr(parms, "name"); /* Try to find a match on the first type */ - tm = typemap_search(op, type, name, &mtype); + tm = typemap_search(tmap_method, type, name, &mtype); if (tm) { if (mtype && SwigType_isarray(mtype)) { Setattr(parms, "tmap:match", mtype); } Delete(mtype); - newop = NewStringf("%s-%s+%s:", op, type, name); + newop = NewStringf("%s-%s+%s:", tmap_method, type, name); tm1 = typemap_search_multi(newop, nextSibling(parms), nmatch); if (tm1) tm = tm1; @@ -1178,20 +1178,20 @@ static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) { * * The node should contain the "type" and "name" attributes for the typemap match on. * input. The typemap code and typemap attribute values are attached onto the node - * prefixed with "tmap:". For example with op="in", the typemap code can be retrieved + * prefixed with "tmap:". For example with tmap_method="in", the typemap code can be retrieved * with a call to Getattr(node, "tmap:in") (this is also the string returned) and the * "noblock" attribute can be retrieved with a call to Getattr(node, "tmap:in:noblock"). * - * op - typemap method, eg "in", "out", "newfree" - * node - the node to attach the typemap and typemap attributes to - * lname - name of variable to substitute $1, $2 etc for - * f - wrapper code to generate into if non null - * actioncode - code to generate into f before the out typemap code, unless + * tmap_method - typemap method, eg "in", "out", "newfree" + * node - the node to attach the typemap and typemap attributes to + * lname - name of variable to substitute $1, $2 etc for + * f - wrapper code to generate into if non null + * actioncode - code to generate into f before the out typemap code, unless * the optimal attribute is set in the out typemap in which case * $1 in the out typemap will be replaced by the code in actioncode. * ----------------------------------------------------------------------------- */ -static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) { +static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) { SwigType *type; SwigType *mtype = 0; String *pname; @@ -1204,14 +1204,14 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, String *symname; String *cname = 0; String *clname = 0; - char *cop = Char(op); + char *cop = Char(tmap_method); int optimal_attribute = 0; int optimal_substitution = 0; int num_substitutions = 0; /* special case, we need to check for 'ref' call and set the default code 'sdef' */ - if (node && Cmp(op, "newfree") == 0) { + if (node && Cmp(tmap_method, "newfree") == 0) { sdef = Swig_ref_call(node, lname); } @@ -1234,7 +1234,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, String *qsn = st ? Swig_symbol_string_qualify(pname, st) : 0; if (qsn) { if (Len(qsn) && !Equal(qsn, pname)) { - tm = typemap_search(op, type, qsn, &mtype); + tm = typemap_search(tmap_method, type, qsn, &mtype); if (tm && (!Getattr(tm, "pname") || strstr(Char(Getattr(tm, "type")), "SWIGTYPE"))) { tm = 0; } @@ -1244,7 +1244,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, } if (!tm) #endif - tm = typemap_search(op, type, pname, &mtype); + tm = typemap_search(tmap_method, type, pname, &mtype); if (!tm) return sdef; @@ -1270,7 +1270,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, Delete(mangle); } sprintf(temp, "%s:%s", cop, ckwname); - Setattr(node, tmop_name(temp), value); + Setattr(node, typemap_method_name(temp), value); if (Cmp(temp, "out:optimal") == 0) optimal_attribute = (Cmp(value, "0") != 0) ? 1 : 0; Delete(value); @@ -1353,23 +1353,23 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, Replace(s, "$symname", symname, DOH_REPLACE_ANY); } - Setattr(node, tmop_name(op), s); + Setattr(node, typemap_method_name(tmap_method), s); if (locals) { sprintf(temp, "%s:locals", cop); - Setattr(node, tmop_name(temp), locals); + Setattr(node, typemap_method_name(temp), locals); Delete(locals); } if (Checkattr(tm, "type", "SWIGTYPE")) { sprintf(temp, "%s:SWIGTYPE", cop); - Setattr(node, tmop_name(temp), "1"); + Setattr(node, typemap_method_name(temp), "1"); } /* Look for warnings */ { String *w; sprintf(temp, "%s:warning", cop); - w = Getattr(node, tmop_name(temp)); + w = Getattr(node, typemap_method_name(temp)); if (w) { Swig_warning(0, Getfile(node), Getline(node), "%s\n", w); } @@ -1379,7 +1379,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, { String *fragment; sprintf(temp, "%s:fragment", cop); - fragment = Getattr(node, tmop_name(temp)); + fragment = Getattr(node, typemap_method_name(temp)); if (fragment) { String *fname = Copy(fragment); Setfile(fname, Getfile(node)); @@ -1402,14 +1402,14 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, return s; } -String *Swig_typemap_lookup_out(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) { +String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) { assert(actioncode); - assert(Cmp(op, "out") == 0); - return Swig_typemap_lookup_impl(op, node, lname, f, actioncode); + assert(Cmp(tmap_method, "out") == 0); + return Swig_typemap_lookup_impl(tmap_method, node, lname, f, actioncode); } -String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f) { - return Swig_typemap_lookup_impl(op, node, lname, f, 0); +String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *node, const_String_or_char_ptr lname, Wrapper *f) { + return Swig_typemap_lookup_impl(tmap_method, node, lname, f, 0); } /* ----------------------------------------------------------------------------- @@ -1423,7 +1423,7 @@ String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *node, const_Strin * A new attribute called "tmap:in:foo" with value "xyz" is attached to p. * ----------------------------------------------------------------------------- */ -static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p) { +static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method, Parm *p) { String *temp = NewStringEmpty(); Parm *kw = Getattr(tm, "kwargs"); while (kw) { @@ -1437,36 +1437,36 @@ static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p value = v; } Clear(temp); - Printf(temp, "%s:%s", op, Getattr(kw, "name")); - Setattr(p, tmop_name(temp), value); + Printf(temp, "%s:%s", tmap_method, Getattr(kw, "name")); + Setattr(p, typemap_method_name(temp), value); Delete(value); kw = nextSibling(kw); } Clear(temp); - Printf(temp, "%s:match_type", op); - Setattr(p, tmop_name(temp), Getattr(tm, "type")); + Printf(temp, "%s:match_type", tmap_method); + Setattr(p, typemap_method_name(temp), Getattr(tm, "type")); Delete(temp); } /* ----------------------------------------------------------------------------- * typemap_warn() * - * If any warning message is attached to this parameter's "tmap:op:warning" + * If any warning message is attached to this parameter's "tmap::warning" * attribute, print that warning message. * ----------------------------------------------------------------------------- */ -static void typemap_warn(const_String_or_char_ptr op, Parm *p) { - String *temp = NewStringf("%s:warning", op); - String *w = Getattr(p, tmop_name(temp)); +static void typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) { + String *temp = NewStringf("%s:warning", tmap_method); + String *w = Getattr(p, typemap_method_name(temp)); Delete(temp); if (w) { Swig_warning(0, Getfile(p), Getline(p), "%s\n", w); } } -static void typemap_emit_code_fragments(const_String_or_char_ptr op, Parm *p) { - String *temp = NewStringf("%s:fragment", op); - String *f = Getattr(p, tmop_name(temp)); +static void typemap_emit_code_fragments(const_String_or_char_ptr tmap_method, Parm *p) { + String *temp = NewStringf("%s:fragment", tmap_method); + String *f = Getattr(p, typemap_method_name(temp)); if (f) { String *fname = Copy(f); Setfile(fname, Getfile(p)); @@ -1496,16 +1496,16 @@ static String *typemap_get_option(Hash *tm, const_String_or_char_ptr name) { * attributes to the parameter for each type in the parameter list. * * This function basically provides the typemap code and typemap attribute values as - * attributes on each parameter prefixed with "tmap:". For example with op="in", the typemap + * attributes on each parameter prefixed with "tmap:". For example with tmap_method="in", the typemap * code can be retrieved for the first parameter with a call to Getattr(parm, "tmap:in") * and the "numinputs" attribute can be retrieved with a call to Getattr(parm, "tmap:in:numinputs"). * - * op - typemap method, eg "in", "out", "newfree" - * parms - parameter list to attach each typemap and all typemap attributes - * f - wrapper code to generate into if non null + * tmap_method - typemap method, eg "in", "out", "newfree" + * parms - parameter list to attach each typemap and all typemap attributes + * f - wrapper code to generate into if non null * ----------------------------------------------------------------------------- */ -void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f) { +void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *parms, Wrapper *f) { Parm *p, *firstp; Hash *tm; int nmatch = 0; @@ -1514,21 +1514,21 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra ParmList *locals; int argnum = 0; char temp[256]; - char *cop = Char(op); + char *cop = Char(tmap_method); String *kwmatch = 0; p = parms; #ifdef SWIG_DEBUG - Printf(stdout, "Swig_typemap_attach_parms: %s\n", op); + Printf(stdout, "Swig_typemap_attach_parms: %s\n", tmap_method); #endif while (p) { argnum++; nmatch = 0; #ifdef SWIG_DEBUG - Printf(stdout, "parms: %s %s %s\n", op, Getattr(p, "name"), Getattr(p, "type")); + Printf(stdout, "parms: %s %s %s\n", tmap_method, Getattr(p, "name"), Getattr(p, "type")); #endif - tm = typemap_search_multi(op, p, &nmatch); + tm = typemap_search_multi(tmap_method, p, &nmatch); #ifdef SWIG_DEBUG if (tm) Printf(stdout, "found: %s\n", tm); @@ -1634,7 +1634,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra if (Checkattr(tm, "type", "SWIGTYPE")) { sprintf(temp, "%s:SWIGTYPE", cop); - Setattr(p, tmop_name(temp), "1"); + Setattr(p, typemap_method_name(temp), "1"); } p = nextSibling(p); } @@ -1651,34 +1651,34 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra /* Attach attributes to object */ #ifdef SWIG_DEBUG - Printf(stdout, "attach: %s %s %s\n", Getattr(firstp, "name"), tmop_name(op), s); + Printf(stdout, "attach: %s %s %s\n", Getattr(firstp, "name"), typemap_method_name(tmap_method), s); #endif - Setattr(firstp, tmop_name(op), s); /* Code object */ + Setattr(firstp, typemap_method_name(tmap_method), s); /* Code object */ if (locals) { sprintf(temp, "%s:locals", cop); - Setattr(firstp, tmop_name(temp), locals); + Setattr(firstp, typemap_method_name(temp), locals); Delete(locals); } /* Attach a link to the next parameter. Needed for multimaps */ sprintf(temp, "%s:next", cop); - Setattr(firstp, tmop_name(temp), p); + Setattr(firstp, typemap_method_name(temp), p); /* Attach kwargs */ - typemap_attach_kwargs(tm, op, firstp); + typemap_attach_kwargs(tm, tmap_method, firstp); /* Print warnings, if any */ - typemap_warn(op, firstp); + typemap_warn(tmap_method, firstp); /* Look for code fragments */ - typemap_emit_code_fragments(op, firstp); + typemap_emit_code_fragments(tmap_method, firstp); /* increase argnum to consider numinputs */ argnum += nmatch - 1; Delete(s); #ifdef SWIG_DEBUG - Printf(stdout, "res: %s %s %s\n", Getattr(firstp, "name"), tmop_name(op), Getattr(firstp, tmop_name(op))); + Printf(stdout, "res: %s %s %s\n", Getattr(firstp, "name"), typemap_method_name(tmap_method), Getattr(firstp, typemap_method_name(tmap_method))); #endif } @@ -1790,7 +1790,7 @@ static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) { if (!syntax_error) { List *l; - String *op; + String *tmap_method; Hash *vars; syntax_error = 1; @@ -1799,7 +1799,7 @@ static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) { if (Len(l) >= 2) { ParmList *to_match_parms; - op = Getitem(l, 0); + tmap_method = Getitem(l, 0); /* the second parameter might contain multiple sub-parameters for multi-argument * typemap matching, so split these parameters apart */ @@ -1843,11 +1843,11 @@ static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) { #endif if (!already_substituting) { already_substituting = 1; - Swig_typemap_attach_parms(op, to_match_parms, f); + Swig_typemap_attach_parms(tmap_method, to_match_parms, f); already_substituting = 0; /* Look for the typemap code */ - attr = NewStringf("tmap:%s", op); + attr = NewStringf("tmap:%s", tmap_method); tm = Getattr(to_match_parms, attr); if (tm) { Printf(attr, "%s", ":next"); @@ -1859,7 +1859,7 @@ static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) { Replace(tm, ki.key, ki.item, DOH_REPLACE_ANY); } /* offer the target language module the chance to make special variable substitutions */ - Language_replace_special_variables(op, tm, to_match_parms); + Language_replace_special_variables(tmap_method, tm, to_match_parms); /* finish up - do the substitution */ Replace(s, dollar_typemap, tm, DOH_REPLACE_ANY); Delete(tm); From 028fcff0a5cbb1926d730c14623cb2445236bbf1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Jul 2009 06:08:36 +0000 Subject: [PATCH 065/352] remove redundant method git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11474 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 8f5178c36..2c9dc00fc 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2196,14 +2196,6 @@ public: return NewStringEmpty(); } - String *PhpTypeFromTypemap(char *tmap_method, Node *n, const_String_or_char_ptr lname) { - String *tms = Swig_typemap_lookup(tmap_method, n, lname, 0); - if (!tms) - return 0; - else - return NewStringf("%s", tms); - } - int abstractConstructorHandler(Node *) { return SWIG_OK; } From 75aa67b99c4099e45f2d89d937f506424f112329 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Jul 2009 06:15:50 +0000 Subject: [PATCH 066/352] rename special_variable_functions testcase to special_variable_macros git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11475 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 +- ...s_runme.cs => special_variable_macros_runme.cs} | 10 +++++----- ...nme.java => special_variable_macros_runme.java} | 14 +++++++------- .../python/special_variable_functions_runme.py | 12 ------------ .../python/special_variable_macros_runme.py | 12 ++++++++++++ ...iable_functions.i => special_variable_macros.i} | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) rename Examples/test-suite/csharp/{special_variable_functions_runme.cs => special_variable_macros_runme.cs} (53%) rename Examples/test-suite/java/{special_variable_functions_runme.java => special_variable_macros_runme.java} (58%) delete mode 100644 Examples/test-suite/python/special_variable_functions_runme.py create mode 100644 Examples/test-suite/python/special_variable_macros_runme.py rename Examples/test-suite/{special_variable_functions.i => special_variable_macros.i} (98%) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 96c7526b8..56097abd9 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -292,7 +292,7 @@ CPP_TEST_CASES += \ smart_pointer_templatevariables \ smart_pointer_typedef \ special_variables \ - special_variable_functions \ + special_variable_macros \ static_array_member \ static_const_member \ static_const_member_2 \ diff --git a/Examples/test-suite/csharp/special_variable_functions_runme.cs b/Examples/test-suite/csharp/special_variable_macros_runme.cs similarity index 53% rename from Examples/test-suite/csharp/special_variable_functions_runme.cs rename to Examples/test-suite/csharp/special_variable_macros_runme.cs index 02d4995d2..abde0053b 100644 --- a/Examples/test-suite/csharp/special_variable_functions_runme.cs +++ b/Examples/test-suite/csharp/special_variable_macros_runme.cs @@ -1,16 +1,16 @@ using System; -using special_variable_functionsNamespace; +using special_variable_macrosNamespace; public class runme { static void Main() { Name name = new Name(); - if (special_variable_functions.testFred(name) != "none") + if (special_variable_macros.testFred(name) != "none") throw new Exception("test failed"); - if (special_variable_functions.testJack(name) != "$specialname") + if (special_variable_macros.testJack(name) != "$specialname") throw new Exception("test failed"); - if (special_variable_functions.testJill(name) != "jilly") + if (special_variable_macros.testJill(name) != "jilly") throw new Exception("test failed"); - if (special_variable_functions.testMary(name) != "SWIGTYPE_p_NameWrap") + if (special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap") throw new Exception("test failed"); NewName newName = NewName.factory("factoryname"); name = newName.getStoredName(); diff --git a/Examples/test-suite/java/special_variable_functions_runme.java b/Examples/test-suite/java/special_variable_macros_runme.java similarity index 58% rename from Examples/test-suite/java/special_variable_functions_runme.java rename to Examples/test-suite/java/special_variable_macros_runme.java index b4d259932..df7aa8c84 100644 --- a/Examples/test-suite/java/special_variable_functions_runme.java +++ b/Examples/test-suite/java/special_variable_macros_runme.java @@ -1,11 +1,11 @@ -import special_variable_functions.*; +import special_variable_macros.*; -public class special_variable_functions_runme { +public class special_variable_macros_runme { static { try { - System.loadLibrary("special_variable_functions"); + 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); @@ -14,13 +14,13 @@ public class special_variable_functions_runme { public static void main(String argv[]) { Name name = new Name(); - if (!special_variable_functions.testFred(name).equals("none")) + if (!special_variable_macros.testFred(name).equals("none")) throw new RuntimeException("test failed"); - if (!special_variable_functions.testJack(name).equals("$specialname")) + if (!special_variable_macros.testJack(name).equals("$specialname")) throw new RuntimeException("test failed"); - if (!special_variable_functions.testJill(name).equals("jilly")) + if (!special_variable_macros.testJill(name).equals("jilly")) throw new RuntimeException("test failed"); - if (!special_variable_functions.testMary(name).equals("SWIGTYPE_p_NameWrap")) + if (!special_variable_macros.testMary(name).equals("SWIGTYPE_p_NameWrap")) throw new RuntimeException("test failed"); NewName newName = NewName.factory("factoryname"); name = newName.getStoredName(); diff --git a/Examples/test-suite/python/special_variable_functions_runme.py b/Examples/test-suite/python/special_variable_functions_runme.py deleted file mode 100644 index 9473880b8..000000000 --- a/Examples/test-suite/python/special_variable_functions_runme.py +++ /dev/null @@ -1,12 +0,0 @@ -import special_variable_functions - -name = special_variable_functions.Name() -if special_variable_functions.testFred(name) != "none": - raise "test failed" -if special_variable_functions.testJack(name) != "$specialname": - raise "test failed" -if special_variable_functions.testJill(name) != "jilly": - raise "test failed" -if special_variable_functions.testMary(name) != "SWIGTYPE_p_NameWrap": - raise "test failed" - diff --git a/Examples/test-suite/python/special_variable_macros_runme.py b/Examples/test-suite/python/special_variable_macros_runme.py new file mode 100644 index 000000000..f1969f704 --- /dev/null +++ b/Examples/test-suite/python/special_variable_macros_runme.py @@ -0,0 +1,12 @@ +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" + diff --git a/Examples/test-suite/special_variable_functions.i b/Examples/test-suite/special_variable_macros.i similarity index 98% rename from Examples/test-suite/special_variable_functions.i rename to Examples/test-suite/special_variable_macros.i index b0c39d73c..06f5805dd 100644 --- a/Examples/test-suite/special_variable_functions.i +++ b/Examples/test-suite/special_variable_macros.i @@ -1,4 +1,4 @@ -%module special_variable_functions +%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 From 7c84046a3615ca209441405d1e11a330e917e549 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 30 Jul 2009 08:39:27 +0000 Subject: [PATCH 067/352] Make SwigPHP_emit_resource_registrations() static. Remove "NEW Destructor style" comment as it's no longer meaningful. Undo indent damage. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11476 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 2c9dc00fc..44a39fd0b 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -130,7 +130,7 @@ extern "C" { static void (*r_prevtracefunc) (SwigType *t, String *mangled, String *clientdata) = 0; } -void SwigPHP_emit_resource_registrations() { +static void SwigPHP_emit_resource_registrations() { Iterator ki; if (!zend_types) @@ -145,7 +145,7 @@ void SwigPHP_emit_resource_registrations() { String *human_name = key; // Write out destructor function header - Printf(s_wrappers, "/* NEW Destructor style */\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key); + Printf(s_wrappers, "static ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key); // write out body if (class_node != NOTCLASS) { @@ -172,7 +172,8 @@ void SwigPHP_emit_resource_registrations() { Printf(s_vdecl, "static int le_swig_%s=0; /* handle for %s */\n", key, human_name); // register with php - Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" "(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\n", key, key, key); + Printf(s_oinit, "le_swig_%s=zend_register_list_destructors_ex" + "(_wrap_destroy%s,NULL,(char *)(SWIGTYPE%s->name),module_number);\n", key, key, key); // store php type in class struct Printf(s_oinit, "SWIG_TypeClientData(SWIGTYPE%s,&le_swig_%s);\n", key, key); From 19c416204710ef9d4f88884e03baf4c8a19ec115 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 30 Jul 2009 08:50:56 +0000 Subject: [PATCH 068/352] Remove dead code. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11477 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 52 ------------------------------------------ 1 file changed, 52 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 44a39fd0b..c498d54cd 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -188,20 +188,6 @@ public: director_language = 1; } - /* Test to see if a type corresponds to something wrapped with a shadow class. */ - - String *is_shadow(SwigType *t) { - String *r = 0; - Node *n = classLookup(t); - if (n) { - r = Getattr(n, "php:proxy"); // Set by classDeclaration() - if (!r) { - r = Getattr(n, "sym:name"); // Not seen by classDeclaration yet, but this is the name - } - } - return r; - } - /* ------------------------------------------------------------ * main() * ------------------------------------------------------------ */ @@ -2159,44 +2145,6 @@ public: return SWIG_OK; } - String * GetShadowReturnType(Node *n) { - SwigType *t = Getattr(n, "type"); - - /* Map type here */ - switch (SwigType_type(t)) { - case T_CHAR: - case T_SCHAR: - case T_UCHAR: - case T_SHORT: - case T_USHORT: - case T_INT: - case T_UINT: - case T_LONG: - case T_ULONG: - case T_FLOAT: - case T_DOUBLE: - case T_BOOL: - case T_STRING: - case T_VOID: - break; - case T_POINTER: - case T_REFERENCE: - case T_USER: - if (is_shadow(t)) { - return NewString(Char(is_shadow(t))); - } - break; - case T_ARRAY: - /* TODO */ - break; - default: - Printf(stderr, "GetShadowReturnType: unhandled data type: %s\n", SwigType_str(t, 0)); - break; - } - - return NewStringEmpty(); - } - int abstractConstructorHandler(Node *) { return SWIG_OK; } From 7e4b1a086d1d2fdc757a2202b2e4e12f0ab38eb9 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 30 Jul 2009 12:16:50 +0000 Subject: [PATCH 069/352] PHP: Cleanups. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11479 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index c498d54cd..551773352 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2041,7 +2041,7 @@ public: virtual int memberfunctionHandler(Node *n) { wrapperType = memberfn; - this->Language::memberfunctionHandler(n); + Language::memberfunctionHandler(n); wrapperType = standard; return SWIG_OK; @@ -2325,10 +2325,6 @@ public: return Language::classDirectorConstructor(n); } - int classDirectorDefaultConstructor(Node *n) { - return Language::classDirectorDefaultConstructor(n); - } - int classDirectorMethod(Node *n, Node *parent, String *super) { int is_void = 0; int is_pointer = 0; @@ -2655,9 +2651,7 @@ public: return status; } - int classDirectorDisown(Node *n) { - /* avoid a warning */ - n = n; + int classDirectorDisown(Node *) { return SWIG_OK; } }; /* class PHP */ From ad0428538d491f24f212d0f6e3ac51a31ba5f421 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 30 Jul 2009 14:01:27 +0000 Subject: [PATCH 070/352] PHP: fix for the cpp_namespace testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11480 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 551773352..fdf88c92e 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1175,6 +1175,11 @@ public: assert(0 <= argno && argno < max_num_of_arguments); String *&pname = arg_names[argno]; const char *pname_cstr = GetChar(p, "name"); + // Just get rid of the C++ namespace part for now. + const char *ptr = NULL; + if ((ptr = strrchr(pname_cstr, ':'))) { + pname_cstr = ptr + 1; + } if (!pname_cstr) { // Unnamed parameter, e.g. int foo(int); } else if (pname == NULL) { From bbcfa0b0892a3b81a0a34340ed25771fe2793546 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Jul 2009 17:42:18 +0000 Subject: [PATCH 071/352] () for multi-argument typemaps git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11481 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../csharp/special_variable_macros_runme.cs | 2 ++ .../java/special_variable_macros_runme.java | 2 ++ .../python/special_variable_macros_runme.py | 2 ++ Examples/test-suite/special_variable_macros.i | 26 ++++++++++++++++++- Source/Swig/typemap.c | 24 +++++++++++++---- 5 files changed, 50 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/csharp/special_variable_macros_runme.cs b/Examples/test-suite/csharp/special_variable_macros_runme.cs index abde0053b..1c0939a1f 100644 --- a/Examples/test-suite/csharp/special_variable_macros_runme.cs +++ b/Examples/test-suite/csharp/special_variable_macros_runme.cs @@ -12,6 +12,8 @@ public class runme { 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"); NewName newName = NewName.factory("factoryname"); name = newName.getStoredName(); } diff --git a/Examples/test-suite/java/special_variable_macros_runme.java b/Examples/test-suite/java/special_variable_macros_runme.java index df7aa8c84..dee629666 100644 --- a/Examples/test-suite/java/special_variable_macros_runme.java +++ b/Examples/test-suite/java/special_variable_macros_runme.java @@ -22,6 +22,8 @@ public class special_variable_macros_runme { 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"); NewName newName = NewName.factory("factoryname"); name = newName.getStoredName(); } diff --git a/Examples/test-suite/python/special_variable_macros_runme.py b/Examples/test-suite/python/special_variable_macros_runme.py index f1969f704..a1d3308ed 100644 --- a/Examples/test-suite/python/special_variable_macros_runme.py +++ b/Examples/test-suite/python/special_variable_macros_runme.py @@ -9,4 +9,6 @@ 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" diff --git a/Examples/test-suite/special_variable_macros.i b/Examples/test-suite/special_variable_macros.i index 06f5805dd..85adf7af1 100644 --- a/Examples/test-suite/special_variable_macros.i +++ b/Examples/test-suite/special_variable_macros.i @@ -83,8 +83,32 @@ const char * testMary(Name *mary) { ////////////////////////////////////////////////////////////////////////////////////// // Multi-arg typemap lookup -#warning TODO!!! +// 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 = 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 != strlen(jim->getNamePtr()->getName()) + 100) + return "size check failed"; + else + return jim->getName(); +} +%} ////////////////////////////////////////////////////////////////////////////////////// // A real use case for $typemap diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 3392fd64c..0fae2344e 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -17,7 +17,7 @@ char cvsroot_typemap_c[] = "$Id$"; #define SWIG_DEBUG #endif -static void replace_embedded_typemap(String *s, String *lname, Wrapper *f); +static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f); /* ----------------------------------------------------------------------------- * Typemaps are stored in a collection of nested hash tables. Something like @@ -1344,7 +1344,13 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No if (locals && f) { typemap_locals(s, locals, f, -1); } - replace_embedded_typemap(s, NewString(lname), f); + + { + ParmList *parm_sublist = NewParm(type, pname); + Setattr(parm_sublist, "lname", lname); + replace_embedded_typemap(s, parm_sublist, f); + Delete(parm_sublist); + } Replace(s, "$name", pname, DOH_REPLACE_ANY); @@ -1643,7 +1649,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p typemap_locals(s, locals, f, argnum); } - replace_embedded_typemap(s, Getattr(firstp, "lname"), f); + replace_embedded_typemap(s, firstp, f); /* Replace the argument number */ sprintf(temp, "%d", argnum); @@ -1759,7 +1765,7 @@ static List *split_embedded_typemap(String *s) { * $typemap(in, (Foo a, int b)) # multi-argument typemap matching %typemap(in) (Foo a, int b) {...} * ----------------------------------------------------------------------------- */ -static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) { +static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f) { char *start = 0; while ((start = strstr(Char(s), "$TYPEMAP("))) { /* note $typemap capitalisation to $TYPEMAP hack */ @@ -1805,11 +1811,19 @@ static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) { * typemap matching, so split these parameters apart */ to_match_parms = Swig_cparse_parms(Getitem(l, 1)); if (to_match_parms) { - Parm *p = to_match_parms;; + Parm *p = to_match_parms; + Parm *sub_p = parm_sublist; + String *empty_string = NewStringEmpty(); + String *lname = empty_string; while (p) { + if (sub_p) { + lname = Getattr(sub_p, "lname"); + sub_p = nextSibling(sub_p); + } Setattr(p, "lname", lname); p = nextSibling(p); } + Delete(empty_string); } /* process optional extra parameters - the variable replacements (undocumented) */ From 43da669254c7788882a0b1639d8fe3be1afc0465 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 30 Jul 2009 18:48:14 +0000 Subject: [PATCH 072/352] improved warning code git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11482 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/lang.cxx | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 36bbf5e9f..e58f2b022 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -881,30 +881,8 @@ int Language::cDeclaration(Node *n) { if (over) over = first_nontemplate(over); if (over && (over != n)) { - SwigType *tc = Copy(decl); - SwigType *td = SwigType_pop_function(tc); - String *oname; - String *cname; - if (CurrentClass) { - oname = NewStringf("%s::%s", ClassName, name); - cname = NewStringf("%s::%s", ClassName, Getattr(over, "name")); - } else { - oname = NewString(name); - cname = NewString(Getattr(over, "name")); - } - - SwigType *tc2 = Copy(Getattr(over, "decl")); - SwigType *td2 = SwigType_pop_function(tc2); - - Swig_warning(WARN_LANG_OVERLOAD_DECL, input_file, line_number, "Overloaded declaration ignored. %s\n", SwigType_str(td, SwigType_namestr(oname))); - Swig_warning(WARN_LANG_OVERLOAD_DECL, Getfile(over), Getline(over), "Previous declaration is %s\n", SwigType_str(td2, SwigType_namestr(cname))); - - Delete(tc2); - Delete(td2); - Delete(tc); - Delete(td); - Delete(oname); - Delete(cname); + Swig_warning(WARN_LANG_OVERLOAD_DECL, input_file, line_number, "Overloaded declaration ignored. %s\n", Swig_name_decl(n)); + Swig_warning(WARN_LANG_OVERLOAD_DECL, Getfile(over), Getline(over), "Previous declaration is %s\n", Swig_name_decl(over)); return SWIG_NOWRAP; } } @@ -985,7 +963,7 @@ int Language::cDeclaration(Node *n) { if (Strncmp(symname, "__dummy_", 8) == 0) { SetFlag(n, "feature:ignore"); Swig_warning(WARN_LANG_TEMPLATE_METHOD_IGNORE, input_file, line_number, - "%%template() contains no name. Template method ignored: %s\n", SwigType_str(decl, SwigType_namestr(Getattr(n,"name")))); + "%%template() contains no name. Template method ignored: %s\n", Swig_name_decl(n)); } } if (!GetFlag(n, "feature:ignore")) From 5215d9227a802466c47ff2f432ddf0bba77fb068 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 31 Jul 2009 12:09:25 +0000 Subject: [PATCH 073/352] [Python] Fix indentation so that we give a useful error if the module can't be loaded. Patch from Gaetan Lehmann in SF#2829853. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11485 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 9 ++++----- Source/Modules/python.cxx | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 4fe0b3ff9..365c7724a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-07-31: olly + [Python] Fix indentation so that we give a useful error if the + module can't be loaded. Patch from Gaetan Lehmann in SF#2829853. + 2009-07-29: wsfulton Add $typemap(method, typelist) special variable macro. This allows the contents of a typemap to be inserted within another typemap. @@ -19,11 +23,6 @@ Version 1.3.40 (in progress) [PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi Amano in SF#2826322. -2009-07-29: olly - [PHP] Fix memory leak in PHP resource destructor for classes - without a destructor and non-class types. Patch from Hitoshi Amano - in SF#2825303. - 2009-07-28: olly [PHP] Update warnings about clashes between identifiers and PHP keywords and automatic renaming to work with the PHP5 class diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index a5ffe294e..5ae98407b 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -728,7 +728,7 @@ public: Printf(f_shadow, tab8 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module); Printv(f_shadow, tab4 tab8, "finally:\n", NULL); Printv(f_shadow, tab8 tab8, "fp.close()\n", NULL); - Printv(f_shadow, tab8 tab8, "return _mod\n", NULL); + Printv(f_shadow, tab4 tab8, "return _mod\n", NULL); Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module); Printv(f_shadow, tab4, "del swig_import_helper\n", NULL); Printv(f_shadow, "else:\n", NULL); From 3df50635216e48d0d5b2eb74a3a5a260572f6551 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 31 Jul 2009 12:17:25 +0000 Subject: [PATCH 074/352] Reinstate old entry I accidentally deleted in the previous commit. Thanks to William for noticing. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11486 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 365c7724a..143d38c76 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -23,6 +23,11 @@ Version 1.3.40 (in progress) [PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi Amano in SF#2826322. +2009-07-29: olly + [PHP] Fix memory leak in PHP resource destructor for classes + without a destructor and non-class types. Patch from Hitoshi Amano + in SF#2825303. + 2009-07-28: olly [PHP] Update warnings about clashes between identifiers and PHP keywords and automatic renaming to work with the PHP5 class From 9444f2cebead5ee8ad6704e859bbe267c453a54a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 3 Aug 2009 13:52:25 +0000 Subject: [PATCH 075/352] PHP: fix for the import_nomodule testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11490 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/php/import_nomodule_runme.php | 20 +++++++++++++++++++ Source/Modules/php.cxx | 12 ++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 Examples/test-suite/php/import_nomodule_runme.php diff --git a/Examples/test-suite/php/import_nomodule_runme.php b/Examples/test-suite/php/import_nomodule_runme.php new file mode 100644 index 000000000..84191fba9 --- /dev/null +++ b/Examples/test-suite/php/import_nomodule_runme.php @@ -0,0 +1,20 @@ + diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index fdf88c92e..3bdbb9812 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1627,8 +1627,14 @@ public: */ Printf(output, "\t\tif (is_resource($r)) {\n"); Printf(output, "\t\t\t$class='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); - Printf(output, "\t\t\treturn new $class($r);\n\t\t}\n"); - Printf(output, "\t\telse return $r;\n"); + if (Getattr(classLookup(Getattr(n, "type")), "module")) { + Printf(output, "\t\t\treturn new $class($r);\n"); + } else { + Printf(output, "\t\t\t$c = new stdClass();\n"); + Printf(output, "\t\t\t$c->_cPtr = $r;\n"); + Printf(output, "\t\t\treturn $c;\n"); + } + Printf(output, "\t\t}\n\t\telse return $r;\n"); } else { Printf(output, "\t\t$this->%s = $r;\n", SWIG_PTR); Printf(output, "\t\treturn $this;\n"); @@ -1928,7 +1934,7 @@ public: Printf(s_phpclasses, "class %s%s ", prefix, shadow_classname); String *baseclass = NULL; - if (base.item) { + if (base.item && Getattr(base.item, "module")) { baseclass = Getattr(base.item, "sym:name"); if (!baseclass) baseclass = Getattr(base.item, "name"); From 31ad548c6ba5305ec4054440bfd18a80ab2a8255 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 3 Aug 2009 18:17:14 +0000 Subject: [PATCH 076/352] Deprecate SWIG_STD_VECTOR_SPECIALIZE_MINIMUM. Deprecate SWIG_STD_VECTOR_SPECIALIZE and replace with SWIG_STD_VECTOR_ENHANCED git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11493 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 17 ++++ Examples/test-suite/constructor_copy.i | 4 - Examples/test-suite/li_std_vector.i | 11 +-- Lib/csharp/std_vector.i | 112 ++++++++++++------------- 4 files changed, 74 insertions(+), 70 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 143d38c76..e44417fdb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,23 @@ Version 1.3.40 (in progress) ============================ +2009-08-03: wsfulton + [C#] The std::vector implementation is improved and now uses $typemap such + that the proxy class for T no longer has to be specified in some macros + for correct C# compilation; the following macros are deprecated, where + CSTYPE was the C# type for the C++ class CTYPE: + + SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE) + usage should be removed altogether + + SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE) + should be replaced with: + SWIG_STD_VECTOR_ENHANCED(CTYPE) + + Some more details in csharp/std_vector.i + + *** POTENTIAL INCOMPATIBILITY *** + 2009-07-31: olly [Python] Fix indentation so that we give a useful error if the module can't be loaded. Patch from Gaetan Lehmann in SF#2829853. diff --git a/Examples/test-suite/constructor_copy.i b/Examples/test-suite/constructor_copy.i index c74268a68..f6bdcb240 100644 --- a/Examples/test-suite/constructor_copy.i +++ b/Examples/test-suite/constructor_copy.i @@ -73,10 +73,6 @@ public: %include "std_vector.i" -#if defined(SWIGCSHARP) -SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(Flow, Space::Flow) -#endif - #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) #define SWIG_GOOD_VECTOR %ignore std::vector::vector(size_type); diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i index c6e2ea9ad..74b3f6e6f 100644 --- a/Examples/test-suite/li_std_vector.i +++ b/Examples/test-suite/li_std_vector.i @@ -75,12 +75,7 @@ const std::vector & vecstructconstptr(const std::vector; %template(StructureConstPtrVector) std::vector; #endif @@ -93,10 +88,6 @@ SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, const int *) %template(StructPtrVector) std::vector; %template(StructConstPtrVector) std::vector; -#if defined(SWIGCSHARP) -SWIG_STD_VECTOR_SPECIALIZE(MyClass, MyClass *) -#endif - #if !defined(SWIGTCL) %inline { struct MyClass {}; diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index d3a4a5541..948fbc017 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -4,23 +4,20 @@ * * std_vector.i * - * SWIG typemaps for std::vector + * SWIG typemaps for std::vector * C# implementation * The C# wrapper is made to look and feel like a C# System.Collections.Generic.List<> collection. * For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code; then the C# wrapper is - * made to look and feel like a typesafe C# System.Collections.ArrayList. All the methods in IList - * are defined, but we don't derive from IList as this is a typesafe collection and the C++ operator== - * must always be defined for the collection type (which it isn't). - * - * Very often the C# generated code will not compile as the C++ template type is not the same as the C# - * proxy type, so use the SWIG_STD_VECTOR_SPECIALIZE or SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro, eg - * - * SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(Klass, SomeNamespace::Klass) - * %template(VectKlass) std::vector; + * made to look and feel like a typesafe C# System.Collections.ArrayList. * * Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with - * C++ std::vector wrappers. IEnumerable<> is replaced by IList<> wherever we are confident that the - * required C++ operator== is available for correct compilation. + * C++ std::vector wrappers. The IList<> interface is also implemented to provide enhanced functionality + * whenever we are confident that the required C++ operator== is available. This is the case for when + * T is a primitive type or a pointer. If T does define an operator==, then use the SWIG_STD_VECTOR_ENHANCED + * macro to obtain this enhanced functionality, for example: + * + * SWIG_STD_VECTOR_ENHANCED(SomeNamespace::Klass) + * %template(VectKlass) std::vector; * * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! * ----------------------------------------------------------------------------- */ @@ -31,14 +28,14 @@ %include // MACRO for use within the std::vector class body -// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps -%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE_TYPE, CSTYPE, CTYPE...) -%typemap(csinterfaces) std::vector "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE\n#endif\n"; +// +%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE_TYPE, CTYPE...) +%typemap(csinterfaces) std::vector "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n"; %typemap(cscode) std::vector %{ public $csclassname(System.Collections.ICollection c) : this() { if (c == null) throw new ArgumentNullException("c"); - foreach (CSTYPE element in c) { + foreach ($typemap(cstype, CTYPE) element in c) { this.Add(element); } } @@ -55,7 +52,7 @@ } } - public CSTYPE this[int index] { + public $typemap(cstype, CTYPE) this[int index] { get { return getitem(index); } @@ -90,7 +87,7 @@ #if SWIG_DOTNET_1 public void CopyTo(System.Array array) #else - public void CopyTo(CSTYPE[] array) + public void CopyTo($typemap(cstype, CTYPE)[] array) #endif { CopyTo(0, array, 0, this.Count); @@ -99,7 +96,7 @@ #if SWIG_DOTNET_1 public void CopyTo(System.Array array, int arrayIndex) #else - public void CopyTo(CSTYPE[] array, int arrayIndex) + public void CopyTo($typemap(cstype, CTYPE)[] array, int arrayIndex) #endif { CopyTo(0, array, arrayIndex, this.Count); @@ -108,7 +105,7 @@ #if SWIG_DOTNET_1 public void CopyTo(int index, System.Array array, int arrayIndex, int count) #else - public void CopyTo(int index, CSTYPE[] array, int arrayIndex, int count) + public void CopyTo(int index, $typemap(cstype, CTYPE)[] array, int arrayIndex, int count) #endif { if (array == null) @@ -128,7 +125,7 @@ } #if !SWIG_DOTNET_1 - System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { + System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> System.Collections.Generic.IEnumerable<$typemap(cstype, CTYPE)>.GetEnumerator() { return new $csclassnameEnumerator(this); } #endif @@ -148,7 +145,7 @@ /// tricky to detect unmanaged code that modifies the collection under our feet. public sealed class $csclassnameEnumerator : System.Collections.IEnumerator #if !SWIG_DOTNET_1 - , System.Collections.Generic.IEnumerator + , System.Collections.Generic.IEnumerator<$typemap(cstype, CTYPE)> #endif { private $csclassname collectionRef; @@ -164,7 +161,7 @@ } // Type-safe iterator Current - public CSTYPE Current { + public $typemap(cstype, CTYPE) Current { get { if (currentIndex == -1) throw new InvalidOperationException("Enumeration not started."); @@ -172,7 +169,7 @@ throw new InvalidOperationException("Enumeration finished."); if (currentObject == null) throw new InvalidOperationException("Collection modified."); - return (CSTYPE)currentObject; + return ($typemap(cstype, CTYPE))currentObject; } } @@ -326,14 +323,13 @@ } %enddef -%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...) -SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CSTYPE, CTYPE) +%define SWIG_STD_VECTOR_MINIMUM(CTYPE...) +SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CTYPE) %enddef // Extra methods added to the collection class if operator== is defined for the class being wrapped -// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps // The class will then implement IList<>, which adds extra functionality -%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE...) +%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...) %extend { bool Contains(const value_type& value) { return std::find($self->begin(), $self->end(), value) != $self->end(); @@ -364,22 +360,24 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CSTYPE, CTYPE) %enddef // Macros for std::vector class specializations -// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps -%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...) +// +%define SWIG_STD_VECTOR_ENHANCED(CTYPE...) namespace std { template<> class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, CSTYPE, CTYPE) - SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, CTYPE) + SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE) }; } %enddef +// Legacy macros +%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...) +#warning SWIG_STD_VECTOR_SPECIALIZE macro deprecated, please see csharp/std_vector.i and switch to SWIG_STD_VECTOR_ENHANCED +SWIG_STD_VECTOR_ENHANCED(CTYPE) +%enddef + %define SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE...) -namespace std { - template<> class vector { - SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE) - }; -} +#warning SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro deprecated, it is no longer required %enddef %{ @@ -399,36 +397,38 @@ namespace std { // primary (unspecialized) class template for std::vector // does not require operator== to be defined template class vector { - SWIG_STD_VECTOR_MINIMUM(T, T) + SWIG_STD_VECTOR_MINIMUM(T) }; // specializations for pointers template class vector { - SWIG_STD_VECTOR_MINIMUM(T, T*) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, T*) + SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T*) }; template class vector { - SWIG_STD_VECTOR_MINIMUM(T, const T*) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, const T*) + SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(const T*) }; // bool is a bit different in the C++ standard template<> class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool, bool) - SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool, bool) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool) + SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool) }; } // template specializations for std::vector // these provide extra collections methods as operator== is defined -SWIG_STD_VECTOR_SPECIALIZE(char, char) -SWIG_STD_VECTOR_SPECIALIZE(sbyte, signed char) -SWIG_STD_VECTOR_SPECIALIZE(byte, unsigned char) -SWIG_STD_VECTOR_SPECIALIZE(short, short) -SWIG_STD_VECTOR_SPECIALIZE(ushort, unsigned short) -SWIG_STD_VECTOR_SPECIALIZE(int, int) -SWIG_STD_VECTOR_SPECIALIZE(uint, unsigned int) -SWIG_STD_VECTOR_SPECIALIZE(int, long) -SWIG_STD_VECTOR_SPECIALIZE(uint, unsigned long) -SWIG_STD_VECTOR_SPECIALIZE(long, long long) -SWIG_STD_VECTOR_SPECIALIZE(ulong, unsigned long long) -SWIG_STD_VECTOR_SPECIALIZE(float, float) -SWIG_STD_VECTOR_SPECIALIZE(double, double) -SWIG_STD_VECTOR_SPECIALIZE(string, std::string) // also requires a %include +SWIG_STD_VECTOR_ENHANCED(char) +SWIG_STD_VECTOR_ENHANCED(signed char) +SWIG_STD_VECTOR_ENHANCED(unsigned char) +SWIG_STD_VECTOR_ENHANCED(short) +SWIG_STD_VECTOR_ENHANCED(unsigned short) +SWIG_STD_VECTOR_ENHANCED(int) +SWIG_STD_VECTOR_ENHANCED(unsigned int) +SWIG_STD_VECTOR_ENHANCED(long) +SWIG_STD_VECTOR_ENHANCED(unsigned long) +SWIG_STD_VECTOR_ENHANCED(long long) +SWIG_STD_VECTOR_ENHANCED(unsigned long long) +SWIG_STD_VECTOR_ENHANCED(float) +SWIG_STD_VECTOR_ENHANCED(double) +SWIG_STD_VECTOR_ENHANCED(std::string) // also requires a %include From 88a934d7f035f4c5201bf4bb383e5001f7885aa6 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 4 Aug 2009 09:32:12 +0000 Subject: [PATCH 077/352] PHP: fix for the wrapmacro testcase 'max' is a built-in function in PHP, so let's rename it to 'maximum' instead. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11495 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/octave/wrapmacro_runme.m | 4 ++-- Examples/test-suite/perl5/wrapmacro_runme.pl | 4 ++-- Examples/test-suite/python/wrapmacro_runme.py | 4 ++-- Examples/test-suite/wrapmacro.i | 7 ++++--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Examples/test-suite/octave/wrapmacro_runme.m b/Examples/test-suite/octave/wrapmacro_runme.m index 4f42883d8..5069f2cca 100644 --- a/Examples/test-suite/octave/wrapmacro_runme.m +++ b/Examples/test-suite/octave/wrapmacro_runme.m @@ -2,7 +2,7 @@ wrapmacro a = 2; b = -1; -wrapmacro.max(a,b); -wrapmacro.max(a/7.0, -b*256); +wrapmacro.maximum(a,b); +wrapmacro.maximum(a/7.0, -b*256); wrapmacro.GUINT16_SWAP_LE_BE_CONSTANT(1); diff --git a/Examples/test-suite/perl5/wrapmacro_runme.pl b/Examples/test-suite/perl5/wrapmacro_runme.pl index f0345e469..8e0154057 100755 --- a/Examples/test-suite/perl5/wrapmacro_runme.pl +++ b/Examples/test-suite/perl5/wrapmacro_runme.pl @@ -9,6 +9,6 @@ require_ok('wrapmacro'); my $a = 2; my $b = -1; -is(wrapmacro::max($a,$b), 2); -is(wrapmacro::max($a/7.0, -$b*256), 256); +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/Examples/test-suite/python/wrapmacro_runme.py b/Examples/test-suite/python/wrapmacro_runme.py index e7a5a3771..0272afd5d 100644 --- a/Examples/test-suite/python/wrapmacro_runme.py +++ b/Examples/test-suite/python/wrapmacro_runme.py @@ -2,6 +2,6 @@ import wrapmacro a = 2 b = -1 -wrapmacro.max(a,b) -wrapmacro.max(a/7.0, -b*256) +wrapmacro.maximum(a,b) +wrapmacro.maximum(a/7.0, -b*256) wrapmacro.GUINT16_SWAP_LE_BE_CONSTANT(1) diff --git a/Examples/test-suite/wrapmacro.i b/Examples/test-suite/wrapmacro.i index 5353e7706..bd5e48b15 100644 --- a/Examples/test-suite/wrapmacro.i +++ b/Examples/test-suite/wrapmacro.i @@ -21,7 +21,8 @@ typedef unsigned short guint16; (guint16) ((guint16) (val) >> 8) | \ (guint16) ((guint16) (val) << 8))) -#define max(a,b) ((a) > (b) ? (a) : (b)) +/* Don't use max(), it's a builtin function for PHP. */ +#define maximum(a,b) ((a) > (b) ? (a) : (b)) %} @@ -41,8 +42,8 @@ type SWIGMACRO_##name(lparams) { /* Here, wrapping the macros */ %wrapmacro(guint16, GUINT16_SWAP_LE_BE_CONSTANT, guint16 val, val); -%wrapmacro(size_t, max, PLIST(size_t a, const size_t& b), PLIST(a, b)); -%wrapmacro(double, max, PLIST(double a, double b), PLIST(a, b)); +%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: From a9f9b7cbbfe503bb302f347c940f25eec3af7d0a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 4 Aug 2009 10:32:25 +0000 Subject: [PATCH 078/352] PHP: fix for the li_math testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11496 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Lib/php/phpkw.swg | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index e44417fdb..4709c232e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.40 (in progress) ============================ +2009-08-04: vmiklos + [PHP] Various mathematical functions (which would conflict + with the built-in PHP ones) are now automatically handled by + adding a 'c_' prefix. + 2009-08-03: wsfulton [C#] The std::vector implementation is improved and now uses $typemap such that the proxy class for T no longer has to be specified in some macros diff --git a/Lib/php/phpkw.swg b/Lib/php/phpkw.swg index 301597eb7..e38f5e6a4 100644 --- a/Lib/php/phpkw.swg +++ b/Lib/php/phpkw.swg @@ -11,6 +11,7 @@ #define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP",sourcefmt="%(lower)s") `x` #define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP") "::" `x` +#define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x` /* @@ -455,7 +456,28 @@ PHPCN(SQLiteResult); PHPCN(SQLiteUnbuffered); PHPCN(SQLiteException); +/* Built-in PHP functions (incomplete). */ +PHPFN(cos); +PHPFN(sin); +PHPFN(tan); +PHPFN(acos); +PHPFN(asin); +PHPFN(atan); +PHPFN(atan2); +PHPFN(cosh); +PHPFN(sinh); +PHPFN(tanh); +PHPFN(exp); +PHPFN(log); +PHPFN(log10); +PHPFN(pow); +PHPFN(sqrt); +PHPFN(ceil); +PHPFN(floor); +PHPFN(fmod); + #undef PHPKW #undef PHPBN1 #undef PHPBN2 #undef PHPCN +#undef PHPFN From 110562d3644895046c41f7f88f876bad4954f1ff Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 4 Aug 2009 15:37:32 +0000 Subject: [PATCH 079/352] [PHP] Fix generated code to work with PHP 5.3. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11498 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/php/phprun.swg | 15 ++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 4709c232e..e403c1b60 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.40 (in progress) ============================ +2009-08-04: olly + [PHP] Fix generated code to work with PHP 5.3. + 2009-08-04: vmiklos [PHP] Various mathematical functions (which would conflict with the built-in PHP ones) are now automatically handled by diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index 992745323..ecdbec2e5 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -25,6 +25,15 @@ extern "C" { # define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_NAMED_FE(ZN, N, A) #endif +#ifndef Z_SET_ISREF +// For PHP < 5.3 +# define Z_SET_ISREF(z) (z)->is_ref = 1 +#endif +#ifndef Z_SET_REFCOUNT +// For PHP < 5.3 +# define Z_SET_REFCOUNT(z, rc) (z)->refcount = (rc) +#endif + #define SWIG_LONG_CONSTANT(N, V) zend_register_long_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) #define SWIG_DOUBLE_CONSTANT(N, V) zend_register_double_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) #define SWIG_STRING_CONSTANT(N, V) zend_register_stringl_constant((char*)#N, sizeof(#N), V, strlen(V), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) @@ -118,13 +127,13 @@ SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject /* class names are stored in lowercase */ php_strtolower(Z_STRVAL_PP(&classname), Z_STRLEN_PP(&classname)); if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &ce TSRMLS_CC) != SUCCESS) { - /* class does not exists */ + /* class does not exist */ object_init(z); } else { object_init_ex(z, *ce); } - z->refcount = 1; - z->is_ref = 1; + Z_SET_REFCOUNT(z, 1); + Z_SET_ISREF(z); zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval), NULL); FREE_ZVAL(classname); } From fb505bf7c9574ba8745919e1e2ec94f9b3b88e3b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 4 Aug 2009 17:48:41 +0000 Subject: [PATCH 080/352] small tidy up git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11500 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/std_vector.i | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index 948fbc017..64aad5807 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -28,7 +28,6 @@ %include // MACRO for use within the std::vector class body -// %define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE_TYPE, CTYPE...) %typemap(csinterfaces) std::vector "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n"; %typemap(cscode) std::vector %{ @@ -359,8 +358,7 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CTYPE) } %enddef -// Macros for std::vector class specializations -// +// Macros for std::vector class specializations/enhancements %define SWIG_STD_VECTOR_ENHANCED(CTYPE...) namespace std { template<> class vector { From 40ea6e5da4de70c4d182ef8e88f0c275092cbd43 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 4 Aug 2009 17:58:17 +0000 Subject: [PATCH 081/352] use so that macros are no longer needed for std::map wrappers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11501 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/csharp/li_std_map_runme.cs | 26 +- Examples/test-suite/li_std_map.i | 12 - Lib/csharp/std_map.i | 426 +++--------------- 3 files changed, 71 insertions(+), 393 deletions(-) diff --git a/Examples/test-suite/csharp/li_std_map_runme.cs b/Examples/test-suite/csharp/li_std_map_runme.cs index 685b20e47..2cdd5f5bc 100644 --- a/Examples/test-suite/csharp/li_std_map_runme.cs +++ b/Examples/test-suite/csharp/li_std_map_runme.cs @@ -169,7 +169,7 @@ public class li_std_map_runme { if (keyStringified != " 1 2 3 4 5") throw new Exception("Wrapped method stringifyKeys test failed. Got " + keyStringified); - // Test a map with a new specialized type (Struct) + // Test a map with a new complex type (Struct) { IntStructMap ismap = new IntStructMap(); for (int i = 0; i < 10; i++) @@ -178,12 +178,12 @@ public class li_std_map_runme { } if (ismap.Count != 10) - throw new Exception("Count test on specialized map failed"); + throw new Exception("Count test on complex type map failed"); foreach (KeyValuePair p in ismap) { if ((p.Key * 10.1) != p.Value.num) - throw new Exception("Iteration test on specialized map failed for index " + p.Key); + throw new Exception("Iteration test on complex type map failed for index " + p.Key); } } @@ -196,12 +196,12 @@ public class li_std_map_runme { } if (ispmap.Count != 10) - throw new Exception("Count test on specialized pointer map failed"); + throw new Exception("Count test on complex type pointer map failed"); foreach (KeyValuePair p in ispmap) { if ((p.Key * 10.1) != p.Value.num) - throw new Exception("Iteration test on specialized pointer map failed for index " + p.Key); + throw new Exception("Iteration test on complex type pointer map failed for index " + p.Key); } } { @@ -212,29 +212,29 @@ public class li_std_map_runme { } if (iscpmap.Count != 10) - throw new Exception("Count test on specialized const pointer map failed"); + throw new Exception("Count test on complex type const pointer map failed"); foreach (KeyValuePair p in iscpmap) { if ((p.Key * 10.1) != p.Value.num) - throw new Exception("Iteration test on specialized const pointer map failed for index " + p.Key); + throw new Exception("Iteration test on complex type const pointer map failed for index " + p.Key); } } - // Test non-specialized map + // Test complex type as key (Struct) { StructIntMap limap = new StructIntMap(); Struct s7 = new Struct(7); Struct s8 = new Struct(8); - limap.setitem(s7 , 8); - if (limap.getitem(s7) != 8) - throw new Exception("Assignment test on non-specialized map failed"); + 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 non-specialized map failed"); + throw new Exception("Key test (1) on complex key map failed"); if (limap.ContainsKey(s8)) - throw new Exception("Key test (2) on non-specialized map failed"); + throw new Exception("Key test (2) on complex key map failed"); } // All done diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i index 356e86df3..d5929d786 100644 --- a/Examples/test-suite/li_std_map.i +++ b/Examples/test-suite/li_std_map.i @@ -46,18 +46,6 @@ struct Struct { %} -#if defined(SWIGCSHARP) - -// Specialize some more non-default map types -SWIG_STD_MAP_SPECIALIZED(int, int *, int, SWIGTYPE_p_int) -SWIG_STD_MAP_SPECIALIZED(int, const int *, int, SWIGTYPE_p_int) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, Struct) -SWIG_STD_MAP_SPECIALIZED(int, Struct *, int, Struct) -SWIG_STD_MAP_SPECIALIZED(int, const Struct *, int, Struct) -SWIG_STD_MAP_SPECIALIZED(Struct *, int, Struct, int) - -#endif - //#if !defined(SWIGR) // Test out some maps with pointer types diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index 3b09861a2..f210a96ba 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -4,25 +4,14 @@ * * std_map.i * - * SWIG typemaps for std::map + * SWIG typemaps for std::map< K, T > * * The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>. * * Using this wrapper is fairly simple. For example, to create a map from integers to doubles use: * * %include - * %template(Map_Int_Double) std::map - * - * Very often the C# generated code will not compile as the C++ template type is not the same as the C# - * proxy type, so use the SWIG_STD_MAP_SPECIALIZED or SWIG_STD_MAP_SPECIALIZED_SIMPLE macros. For example: - * - * SWIG_STD_MAP_SPECIALIZED(MyCppKeyClass, MyCppValueClass, MyCsKeyClass, MyCsValueClass) - * %template(Map_MyCppKeyClass_MyCppValueClass) std::map; - * - * Or if the C# class names are the same as the C++ class names, you can use: - * - * SWIG_STD_MAP_SPECIALIZED_SIMPLE(MyKeyClass, MyValueClass) - * %template(Map_MyCppKeyClass_MyCppValueClass) std::map; + * %template(MapIntDouble) std::map * * Notes: * 1) For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code. In this case @@ -39,69 +28,13 @@ #include %} -// A minimal implementation to be used when no specialization exists. -%define SWIG_STD_MAP_MINIMAL_INTERNAL(K, T) - public: - map(); - map(const map &other); +/* K is the C++ key type, T is the C++ value type */ +%define SWIG_STD_MAP_INTERNAL(K, T) - typedef K key_type; - typedef T mapped_type; - typedef size_t size_type; - size_type size() const; - bool empty() const; - %rename(Clear) clear; - void clear(); - %extend { - const mapped_type& getitem(const key_type& key) throw (std::out_of_range) { - std::map::iterator iter = $self->find(key); - if (iter != $self->end()) - return iter->second; - else - throw std::out_of_range("key not found"); - } - - void setitem(const key_type& key, const mapped_type& x) { - (*$self)[key] = x; - } - - bool ContainsKey(const key_type& key) { - std::map::iterator iter = $self->find(key); - return iter != $self->end(); - } - - void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) { - std::map::iterator iter = $self->find(key); - if (iter != $self->end()) - throw std::out_of_range("key already exists"); - $self->insert(std::pair(key, val)); - } - - bool Remove(const key_type& key) { - std::map::iterator iter = $self->find(key); - if (iter != $self->end()) { - $self->erase(iter); - return true; - } - return false; - } - - } - -%enddef - -/* The specialized std::map implementation - * K is the C++ key type - * T is the C++ value type - * CSKEYTYPE is the C# key type - * CSVALUETYPE is the C# value type - */ -%define SWIG_STD_MAP_SPECIALIZED_INTERNAL(K, T, CSKEYTYPE, CSVALUETYPE) -// add typemaps here -%typemap(csinterfaces) std::map "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary\n#endif\n"; +%typemap(csinterfaces) std::map< K, T > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n#endif\n"; %typemap(cscode) std::map %{ - public CSVALUETYPE this[CSKEYTYPE key] { + public $typemap(cstype, T) this[$typemap(cstype, K) key] { get { return getitem(key); } @@ -111,12 +44,12 @@ } } - public bool TryGetValue(CSKEYTYPE key, out CSVALUETYPE value) { + public bool TryGetValue($typemap(cstype, K) key, out $typemap(cstype, T) value) { if (this.ContainsKey(key)) { value = this[key]; return true; } - value = default(CSVALUETYPE); + value = default($typemap(cstype, T)); return false; } @@ -134,9 +67,9 @@ #if !SWIG_DOTNET_1 - public System.Collections.Generic.ICollection Keys { + public System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys { get { - System.Collections.Generic.ICollection keys = new System.Collections.Generic.List(); + System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new System.Collections.Generic.List<$typemap(cstype, K)>(); IntPtr iter = create_iterator_begin(); try { while (true) { @@ -148,21 +81,21 @@ } } - public System.Collections.Generic.ICollection Values { + public System.Collections.Generic.ICollection<$typemap(cstype, T)> Values { get { - System.Collections.Generic.ICollection vals = new System.Collections.Generic.List(); - foreach (System.Collections.Generic.KeyValuePair pair in this) { + System.Collections.Generic.ICollection<$typemap(cstype, T)> vals = new System.Collections.Generic.List<$typemap(cstype, T)>(); + foreach (System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> pair in this) { vals.Add(pair.Value); } return vals; } } - public void Add(System.Collections.Generic.KeyValuePair item) { + public void Add(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { Add(item.Key, item.Value); } - public bool Remove(System.Collections.Generic.KeyValuePair item) { + public bool Remove(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { if (Contains(item)) { return Remove(item.Key); } else { @@ -170,7 +103,7 @@ } } - public bool Contains(System.Collections.Generic.KeyValuePair item) { + public bool Contains(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> item) { if (this[item.Key] == item.Value) { return true; } else { @@ -178,11 +111,11 @@ } } - public void CopyTo(System.Collections.Generic.KeyValuePair[] array) { + public void CopyTo(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array) { CopyTo(array, 0); } - public void CopyTo(System.Collections.Generic.KeyValuePair[] array, int arrayIndex) { + public void CopyTo(System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>[] array, int arrayIndex) { if (array == null) throw new ArgumentNullException("array"); if (arrayIndex < 0) @@ -192,14 +125,14 @@ if (arrayIndex+this.Count > array.Length) throw new ArgumentException("Number of elements to copy is too large."); - System.Collections.Generic.IList keyList = new System.Collections.Generic.List(this.Keys); + System.Collections.Generic.IList<$typemap(cstype, K)> keyList = new System.Collections.Generic.List<$typemap(cstype, K)>(this.Keys); for (int i = 0; i < keyList.Count; i++) { - CSKEYTYPE currentKey = keyList[i]; - array.SetValue(new System.Collections.Generic.KeyValuePair(currentKey, this[currentKey]), arrayIndex+i); + $typemap(cstype, K) currentKey = keyList[i]; + array.SetValue(new System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, this[currentKey]), arrayIndex+i); } } - System.Collections.Generic.IEnumerator> System.Collections.Generic.IEnumerable>.GetEnumerator() { + System.Collections.Generic.IEnumerator> System.Collections.Generic.IEnumerable>.GetEnumerator() { return new $csclassnameEnumerator(this); } @@ -217,24 +150,24 @@ /// collection but not when one of the elements of the collection is modified as it is a bit /// tricky to detect unmanaged code that modifies the collection under our feet. public sealed class $csclassnameEnumerator : System.Collections.IEnumerator, - System.Collections.Generic.IEnumerator> + System.Collections.Generic.IEnumerator> { private $csclassname collectionRef; - private System.Collections.Generic.IList keyCollection; + private System.Collections.Generic.IList<$typemap(cstype, K)> keyCollection; private int currentIndex; private object currentObject; private int currentSize; public $csclassnameEnumerator($csclassname collection) { collectionRef = collection; - keyCollection = new System.Collections.Generic.List(collection.Keys); + keyCollection = new System.Collections.Generic.List<$typemap(cstype, K)>(collection.Keys); currentIndex = -1; currentObject = null; currentSize = collectionRef.Count; } // Type-safe iterator Current - public System.Collections.Generic.KeyValuePair Current { + public System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)> Current { get { if (currentIndex == -1) throw new InvalidOperationException("Enumeration not started."); @@ -242,7 +175,7 @@ throw new InvalidOperationException("Enumeration finished."); if (currentObject == null) throw new InvalidOperationException("Collection modified."); - return (System.Collections.Generic.KeyValuePair)currentObject; + return (System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>)currentObject; } } @@ -258,8 +191,8 @@ bool moveOkay = (currentIndex+1 < size) && (size == currentSize); if (moveOkay) { currentIndex++; - CSKEYTYPE currentKey = keyCollection[currentIndex]; - currentObject = new System.Collections.Generic.KeyValuePair(currentKey, collectionRef[currentKey]); + $typemap(cstype, K) currentKey = keyCollection[currentIndex]; + currentObject = new System.Collections.Generic.KeyValuePair<$typemap(cstype, K), $typemap(cstype, T)>(currentKey, collectionRef[currentKey]); } else { currentObject = null; } @@ -285,7 +218,7 @@ public: map(); - map(const map &other); + map(const map< K, T > &other); typedef K key_type; typedef T mapped_type; @@ -296,7 +229,7 @@ void clear(); %extend { const mapped_type& getitem(const key_type& key) throw (std::out_of_range) { - std::map::iterator iter = $self->find(key); + std::map< K,T >::iterator iter = $self->find(key); if (iter != $self->end()) return iter->second; else @@ -308,19 +241,19 @@ } bool ContainsKey(const key_type& key) { - std::map::iterator iter = $self->find(key); + std::map< K, T >::iterator iter = $self->find(key); return iter != $self->end(); } void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) { - std::map::iterator iter = $self->find(key); + std::map< K, T >::iterator iter = $self->find(key); if (iter != $self->end()) throw std::out_of_range("key already exists"); - $self->insert(std::pair(key, val)); + $self->insert(std::pair< K, T >(key, val)); } bool Remove(const key_type& key) { - std::map::iterator iter = $self->find(key); + std::map< K, T >::iterator iter = $self->find(key); if (iter != $self->end()) { $self->erase(iter); return true; @@ -329,15 +262,15 @@ } // create_iterator_begin() and get_next_key() work together to provide a collection of keys to C# - %apply void *VOID_INT_PTR { std::map::iterator *std::map::create_iterator_begin } - %apply void *VOID_INT_PTR { std::map::iterator *swigiterator } + %apply void *VOID_INT_PTR { std::map< K, T >::iterator *create_iterator_begin } + %apply void *VOID_INT_PTR { std::map< K, T >::iterator *swigiterator } - std::map::iterator *create_iterator_begin() { - return new std::map::iterator($self->begin()); + std::map< K, T >::iterator *create_iterator_begin() { + return new std::map< K, T >::iterator($self->begin()); } - const key_type& get_next_key(std::map::iterator *swigiterator) throw (std::out_of_range) { - std::map::iterator iter = *swigiterator; + const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) throw (std::out_of_range) { + std::map< K, T >::iterator iter = *swigiterator; if (iter == $self->end()) { delete swigiterator; throw std::out_of_range("no more map elements"); @@ -348,275 +281,32 @@ } -%csmethodmodifiers std::map::size "private" -%csmethodmodifiers std::map::getitem "private" -%csmethodmodifiers std::map::setitem "private" -%csmethodmodifiers std::map::create_iterator_begin "private" -%csmethodmodifiers std::map::get_next_key "private" - %enddef - -// Main specialization macros -%define SWIG_STD_MAP_SPECIALIZED(K, T, CSKEY, CSVAL) -namespace std { - template<> class map { - SWIG_STD_MAP_SPECIALIZED_INTERNAL(K, T, CSKEY, CSVAL) - }; -} -%enddef - -%define SWIG_STD_MAP_SPECIALIZED_SIMPLE(K, T) - SWIG_STD_MAP_SPECIALIZED(K, T, K, T) -%enddef - -// Old macros (deprecated) -%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) -#warning specialize_std_map_on_key ignored - macro is deprecated, please use SWIG_STD_MAP_MINIMAL_INTERNAL in Lib/csharp/std_map.i -%enddef - -%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) -#warning specialize_std_map_on_value ignored - macro is deprecated, please use SWIG_STD_MAP_MINIMAL_INTERNAL in Lib/csharp/std_map.i -%enddef - -%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) -#warning specialize_std_map_on_both ignored - macro is deprecated, please use SWIG_STD_MAP_MINIMAL_INTERNAL in Lib/csharp/std_map.i -%enddef +%csmethodmodifiers std::map::size "private" +%csmethodmodifiers std::map::getitem "private" +%csmethodmodifiers std::map::setitem "private" +%csmethodmodifiers std::map::create_iterator_begin "private" +%csmethodmodifiers std::map::get_next_key "private" // Default implementation namespace std { template class map { - SWIG_STD_MAP_MINIMAL_INTERNAL(K, T) + SWIG_STD_MAP_INTERNAL(K, T) }; } -// specializations for built-ins -SWIG_STD_MAP_SPECIALIZED(std::string, std::string, string, string) -SWIG_STD_MAP_SPECIALIZED(std::string, bool, string, bool) -SWIG_STD_MAP_SPECIALIZED(std::string, int, string, int) -SWIG_STD_MAP_SPECIALIZED(std::string, unsigned long long, string, ulong) -SWIG_STD_MAP_SPECIALIZED(std::string, unsigned long, string, uint) -SWIG_STD_MAP_SPECIALIZED(std::string, unsigned short, string, ushort) -SWIG_STD_MAP_SPECIALIZED(std::string, long long, string, long) -SWIG_STD_MAP_SPECIALIZED(std::string, unsigned int, string, uint) -SWIG_STD_MAP_SPECIALIZED(std::string, unsigned char, string, byte) -SWIG_STD_MAP_SPECIALIZED(std::string, signed char, string, sbyte) -SWIG_STD_MAP_SPECIALIZED(std::string, double, string, double) -SWIG_STD_MAP_SPECIALIZED(std::string, short, string, short) -SWIG_STD_MAP_SPECIALIZED(std::string, float, string, float) -SWIG_STD_MAP_SPECIALIZED(std::string, char, string, char) -SWIG_STD_MAP_SPECIALIZED(std::string, long, string, int) -SWIG_STD_MAP_SPECIALIZED(bool, std::string, bool, string) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, bool) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, int) -SWIG_STD_MAP_SPECIALIZED(bool, unsigned long long, bool, ulong) -SWIG_STD_MAP_SPECIALIZED(bool, unsigned long, bool, uint) -SWIG_STD_MAP_SPECIALIZED(bool, unsigned short, bool, ushort) -SWIG_STD_MAP_SPECIALIZED(bool, long long, bool, long) -SWIG_STD_MAP_SPECIALIZED(bool, unsigned int, bool, uint) -SWIG_STD_MAP_SPECIALIZED(bool, unsigned char, bool, byte) -SWIG_STD_MAP_SPECIALIZED(bool, signed char, bool, sbyte) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, double) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, short) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, float) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, char) -SWIG_STD_MAP_SPECIALIZED(bool, long, bool, int) -SWIG_STD_MAP_SPECIALIZED(int, std::string, int, string) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, bool) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, int) -SWIG_STD_MAP_SPECIALIZED(int, unsigned long long, int, ulong) -SWIG_STD_MAP_SPECIALIZED(int, unsigned long, int, uint) -SWIG_STD_MAP_SPECIALIZED(int, unsigned short, int, ushort) -SWIG_STD_MAP_SPECIALIZED(int, long long, int, long) -SWIG_STD_MAP_SPECIALIZED(int, unsigned int, int, uint) -SWIG_STD_MAP_SPECIALIZED(int, unsigned char, int, byte) -SWIG_STD_MAP_SPECIALIZED(int, signed char, int, sbyte) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, double) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, short) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, float) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, char) -SWIG_STD_MAP_SPECIALIZED(int, long, int, int) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, std::string, ulong, string) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, bool, ulong, bool) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, int, ulong, int) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned long long, ulong, ulong) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned long, ulong, uint) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned short, ulong, ushort) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, long long, ulong, long) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned int, ulong, uint) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned char, ulong, byte) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, signed char, ulong, sbyte) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, double, ulong, double) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, short, ulong, short) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, float, ulong, float) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, char, ulong, char) -SWIG_STD_MAP_SPECIALIZED(unsigned long long, long, ulong, int) -SWIG_STD_MAP_SPECIALIZED(unsigned long, std::string, uint, string) -SWIG_STD_MAP_SPECIALIZED(unsigned long, bool, uint, bool) -SWIG_STD_MAP_SPECIALIZED(unsigned long, int, uint, int) -SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned long long, uint, ulong) -SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned long, uint, uint) -SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned short, uint, ushort) -SWIG_STD_MAP_SPECIALIZED(unsigned long, long long, uint, long) -SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned int, uint, uint) -SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned char, uint, byte) -SWIG_STD_MAP_SPECIALIZED(unsigned long, signed char, uint, sbyte) -SWIG_STD_MAP_SPECIALIZED(unsigned long, double, uint, double) -SWIG_STD_MAP_SPECIALIZED(unsigned long, short, uint, short) -SWIG_STD_MAP_SPECIALIZED(unsigned long, float, uint, float) -SWIG_STD_MAP_SPECIALIZED(unsigned long, char, uint, char) -SWIG_STD_MAP_SPECIALIZED(unsigned long, long, uint, int) -SWIG_STD_MAP_SPECIALIZED(unsigned short, std::string, ushort, string) -SWIG_STD_MAP_SPECIALIZED(unsigned short, bool, ushort, bool) -SWIG_STD_MAP_SPECIALIZED(unsigned short, int, ushort, int) -SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned long long, ushort, ulong) -SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned long, ushort, uint) -SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned short, ushort, ushort) -SWIG_STD_MAP_SPECIALIZED(unsigned short, long long, ushort, long) -SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned int, ushort, uint) -SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned char, ushort, byte) -SWIG_STD_MAP_SPECIALIZED(unsigned short, signed char, ushort, sbyte) -SWIG_STD_MAP_SPECIALIZED(unsigned short, double, ushort, double) -SWIG_STD_MAP_SPECIALIZED(unsigned short, short, ushort, short) -SWIG_STD_MAP_SPECIALIZED(unsigned short, float, ushort, float) -SWIG_STD_MAP_SPECIALIZED(unsigned short, char, ushort, char) -SWIG_STD_MAP_SPECIALIZED(unsigned short, long, ushort, int) -SWIG_STD_MAP_SPECIALIZED(long long, std::string, long, string) -SWIG_STD_MAP_SPECIALIZED(long long, bool, long, bool) -SWIG_STD_MAP_SPECIALIZED(long long, int, long, int) -SWIG_STD_MAP_SPECIALIZED(long long, unsigned long long, long, ulong) -SWIG_STD_MAP_SPECIALIZED(long long, unsigned long, long, uint) -SWIG_STD_MAP_SPECIALIZED(long long, unsigned short, long, ushort) -SWIG_STD_MAP_SPECIALIZED(long long, long long, long, long) -SWIG_STD_MAP_SPECIALIZED(long long, unsigned int, long, uint) -SWIG_STD_MAP_SPECIALIZED(long long, unsigned char, long, byte) -SWIG_STD_MAP_SPECIALIZED(long long, signed char, long, sbyte) -SWIG_STD_MAP_SPECIALIZED(long long, double, long, double) -SWIG_STD_MAP_SPECIALIZED(long long, short, long, short) -SWIG_STD_MAP_SPECIALIZED(long long, float, long, float) -SWIG_STD_MAP_SPECIALIZED(long long, char, long, char) -SWIG_STD_MAP_SPECIALIZED(long long, long, long, int) -SWIG_STD_MAP_SPECIALIZED(unsigned int, std::string, uint, string) -SWIG_STD_MAP_SPECIALIZED(unsigned int, bool, uint, bool) -SWIG_STD_MAP_SPECIALIZED(unsigned int, int, uint, int) -SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned long long, uint, ulong) -SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned long, uint, uint) -SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned short, uint, ushort) -SWIG_STD_MAP_SPECIALIZED(unsigned int, long long, uint, long) -SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned int, uint, uint) -SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned char, uint, byte) -SWIG_STD_MAP_SPECIALIZED(unsigned int, signed char, uint, sbyte) -SWIG_STD_MAP_SPECIALIZED(unsigned int, double, uint, double) -SWIG_STD_MAP_SPECIALIZED(unsigned int, short, uint, short) -SWIG_STD_MAP_SPECIALIZED(unsigned int, float, uint, float) -SWIG_STD_MAP_SPECIALIZED(unsigned int, char, uint, char) -SWIG_STD_MAP_SPECIALIZED(unsigned int, long, uint, int) -SWIG_STD_MAP_SPECIALIZED(unsigned char, std::string, byte, string) -SWIG_STD_MAP_SPECIALIZED(unsigned char, bool, byte, bool) -SWIG_STD_MAP_SPECIALIZED(unsigned char, int, byte, int) -SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned long long, byte, ulong) -SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned long, byte, uint) -SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned short, byte, ushort) -SWIG_STD_MAP_SPECIALIZED(unsigned char, long long, byte, long) -SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned int, byte, uint) -SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned char, byte, byte) -SWIG_STD_MAP_SPECIALIZED(unsigned char, signed char, byte, sbyte) -SWIG_STD_MAP_SPECIALIZED(unsigned char, double, byte, double) -SWIG_STD_MAP_SPECIALIZED(unsigned char, short, byte, short) -SWIG_STD_MAP_SPECIALIZED(unsigned char, float, byte, float) -SWIG_STD_MAP_SPECIALIZED(unsigned char, char, byte, char) -SWIG_STD_MAP_SPECIALIZED(unsigned char, long, byte, int) -SWIG_STD_MAP_SPECIALIZED(signed char, std::string, sbyte, string) -SWIG_STD_MAP_SPECIALIZED(signed char, bool, sbyte, bool) -SWIG_STD_MAP_SPECIALIZED(signed char, int, sbyte, int) -SWIG_STD_MAP_SPECIALIZED(signed char, unsigned long long, sbyte, ulong) -SWIG_STD_MAP_SPECIALIZED(signed char, unsigned long, sbyte, uint) -SWIG_STD_MAP_SPECIALIZED(signed char, unsigned short, sbyte, ushort) -SWIG_STD_MAP_SPECIALIZED(signed char, long long, sbyte, long) -SWIG_STD_MAP_SPECIALIZED(signed char, unsigned int, sbyte, uint) -SWIG_STD_MAP_SPECIALIZED(signed char, unsigned char, sbyte, byte) -SWIG_STD_MAP_SPECIALIZED(signed char, signed char, sbyte, sbyte) -SWIG_STD_MAP_SPECIALIZED(signed char, double, sbyte, double) -SWIG_STD_MAP_SPECIALIZED(signed char, short, sbyte, short) -SWIG_STD_MAP_SPECIALIZED(signed char, float, sbyte, float) -SWIG_STD_MAP_SPECIALIZED(signed char, char, sbyte, char) -SWIG_STD_MAP_SPECIALIZED(signed char, long, sbyte, int) -SWIG_STD_MAP_SPECIALIZED(double, std::string, double, string) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, bool) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, int) -SWIG_STD_MAP_SPECIALIZED(double, unsigned long long, double, ulong) -SWIG_STD_MAP_SPECIALIZED(double, unsigned long, double, uint) -SWIG_STD_MAP_SPECIALIZED(double, unsigned short, double, ushort) -SWIG_STD_MAP_SPECIALIZED(double, long long, double, long) -SWIG_STD_MAP_SPECIALIZED(double, unsigned int, double, uint) -SWIG_STD_MAP_SPECIALIZED(double, unsigned char, double, byte) -SWIG_STD_MAP_SPECIALIZED(double, signed char, double, sbyte) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, double) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, short) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, float) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, char) -SWIG_STD_MAP_SPECIALIZED(double, long, double, int) -SWIG_STD_MAP_SPECIALIZED(short, std::string, short, string) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, bool) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, int) -SWIG_STD_MAP_SPECIALIZED(short, unsigned long long, short, ulong) -SWIG_STD_MAP_SPECIALIZED(short, unsigned long, short, uint) -SWIG_STD_MAP_SPECIALIZED(short, unsigned short, short, ushort) -SWIG_STD_MAP_SPECIALIZED(short, long long, short, long) -SWIG_STD_MAP_SPECIALIZED(short, unsigned int, short, uint) -SWIG_STD_MAP_SPECIALIZED(short, unsigned char, short, byte) -SWIG_STD_MAP_SPECIALIZED(short, signed char, short, sbyte) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, double) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, short) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, float) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, char) -SWIG_STD_MAP_SPECIALIZED(short, long, short, int) -SWIG_STD_MAP_SPECIALIZED(float, std::string, float, string) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, bool) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, int) -SWIG_STD_MAP_SPECIALIZED(float, unsigned long long, float, ulong) -SWIG_STD_MAP_SPECIALIZED(float, unsigned long, float, uint) -SWIG_STD_MAP_SPECIALIZED(float, unsigned short, float, ushort) -SWIG_STD_MAP_SPECIALIZED(float, long long, float, long) -SWIG_STD_MAP_SPECIALIZED(float, unsigned int, float, uint) -SWIG_STD_MAP_SPECIALIZED(float, unsigned char, float, byte) -SWIG_STD_MAP_SPECIALIZED(float, signed char, float, sbyte) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, double) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, short) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, float) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, char) -SWIG_STD_MAP_SPECIALIZED(float, long, float, int) -SWIG_STD_MAP_SPECIALIZED(char, std::string, char, string) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, bool) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, int) -SWIG_STD_MAP_SPECIALIZED(char, unsigned long long, char, ulong) -SWIG_STD_MAP_SPECIALIZED(char, unsigned long, char, uint) -SWIG_STD_MAP_SPECIALIZED(char, unsigned short, char, ushort) -SWIG_STD_MAP_SPECIALIZED(char, long long, char, long) -SWIG_STD_MAP_SPECIALIZED(char, unsigned int, char, uint) -SWIG_STD_MAP_SPECIALIZED(char, unsigned char, char, byte) -SWIG_STD_MAP_SPECIALIZED(char, signed char, char, sbyte) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, double) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, short) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, float) -SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, char) -SWIG_STD_MAP_SPECIALIZED(char, long, char, int) -SWIG_STD_MAP_SPECIALIZED(long, std::string, int, string) -SWIG_STD_MAP_SPECIALIZED(long, bool, int, bool) -SWIG_STD_MAP_SPECIALIZED(long, int, int, int) -SWIG_STD_MAP_SPECIALIZED(long, unsigned long long, int, ulong) -SWIG_STD_MAP_SPECIALIZED(long, unsigned long, int, uint) -SWIG_STD_MAP_SPECIALIZED(long, unsigned short, int, ushort) -SWIG_STD_MAP_SPECIALIZED(long, long long, int, long) -SWIG_STD_MAP_SPECIALIZED(long, unsigned int, int, uint) -SWIG_STD_MAP_SPECIALIZED(long, unsigned char, int, byte) -SWIG_STD_MAP_SPECIALIZED(long, signed char, int, sbyte) -SWIG_STD_MAP_SPECIALIZED(long, double, int, double) -SWIG_STD_MAP_SPECIALIZED(long, short, int, short) -SWIG_STD_MAP_SPECIALIZED(long, float, int, float) -SWIG_STD_MAP_SPECIALIZED(long, char, int, char) -SWIG_STD_MAP_SPECIALIZED(long, long, int, int) -// add specializations here +// Legacy macros (deprecated) +%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO) +#warning specialize_std_map_on_key ignored - macro is deprecated and no longer necessary +%enddef +%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO) +#warning specialize_std_map_on_value ignored - macro is deprecated and no longer necessary +%enddef + +%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO) +#warning specialize_std_map_on_both ignored - macro is deprecated and no longer necessary +%enddef From e27c32d885042a5c98c107b54be8ed78381a1929 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 5 Aug 2009 09:26:25 +0000 Subject: [PATCH 082/352] PHP: fix PHP 5.3 support git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11502 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/phprun.swg | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index ecdbec2e5..3f762a3e5 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -25,13 +25,13 @@ extern "C" { # define SWIG_ZEND_NAMED_FE(ZN, N, A) ZEND_NAMED_FE(ZN, N, A) #endif -#ifndef Z_SET_ISREF +#ifndef Z_SET_ISREF_P // For PHP < 5.3 -# define Z_SET_ISREF(z) (z)->is_ref = 1 +# define Z_SET_ISREF_P(z) (z)->is_ref = 1 #endif -#ifndef Z_SET_REFCOUNT +#ifndef Z_SET_REFCOUNT_P // For PHP < 5.3 -# define Z_SET_REFCOUNT(z, rc) (z)->refcount = (rc) +# define Z_SET_REFCOUNT_P(z, rc) (z)->refcount = (rc) #endif #define SWIG_LONG_CONSTANT(N, V) zend_register_long_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) @@ -132,8 +132,8 @@ SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject } else { object_init_ex(z, *ce); } - Z_SET_REFCOUNT(z, 1); - Z_SET_ISREF(z); + Z_SET_REFCOUNT_P(z, 1); + Z_SET_ISREF_P(z); zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval), NULL); FREE_ZVAL(classname); } From 76a90e6606301d11be0260a386b8b2f78e855ba7 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 5 Aug 2009 11:37:45 +0000 Subject: [PATCH 083/352] PHP: define our own ZEND_MODULE_BUILD_ID macro for PHP <= 5.3 This silences the warning, but causes no breakage for future releases. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11504 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 3bdbb9812..0591d971c 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -501,6 +501,10 @@ public: Printf(s_entry, "static zend_function_entry %s_functions[] = {\n", module); /* start the init section */ + Append(s_init, "#if ZEND_MODULE_API_NO <= 20090626\n"); + Append(s_init, "#undef ZEND_MODULE_BUILD_ID\n"); + Append(s_init, "#define ZEND_MODULE_BUILD_ID (char*)\"API\" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA\n"); + Append(s_init, "#endif\n"); Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n" "#if ZEND_MODULE_API_NO > 20010900\n" " STANDARD_MODULE_HEADER,\n" "#endif\n", NIL); Printf(s_init, " (char*)\"%s\",\n", module); Printf(s_init, " %s_functions,\n", module); From 5161a12868965e29740a8b7fc5581c982c74d423 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 5 Aug 2009 12:37:56 +0000 Subject: [PATCH 084/352] PHP: detect if a non-object is passed to check::classname() in the testsuite git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11505 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/tests.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Examples/test-suite/php/tests.php b/Examples/test-suite/php/tests.php index ad58ac9d8..57c5c4788 100644 --- a/Examples/test-suite/php/tests.php +++ b/Examples/test-suite/php/tests.php @@ -70,6 +70,8 @@ class check { } 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; } From 41d3c989937dca5e12651ed4365f362f3e8427b7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 Aug 2009 21:40:49 +0000 Subject: [PATCH 085/352] fix $typemap() when the type contains template parameters git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11506 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../csharp/special_variable_macros_runme.cs | 2 ++ .../java/special_variable_macros_runme.java | 2 ++ .../python/special_variable_macros_runme.py | 2 ++ Examples/test-suite/special_variable_macros.i | 34 +++++++++++++++++++ Source/Swig/typemap.c | 10 ++++-- 5 files changed, 48 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/csharp/special_variable_macros_runme.cs b/Examples/test-suite/csharp/special_variable_macros_runme.cs index 1c0939a1f..bd6fd4b04 100644 --- a/Examples/test-suite/csharp/special_variable_macros_runme.cs +++ b/Examples/test-suite/csharp/special_variable_macros_runme.cs @@ -14,6 +14,8 @@ public class runme { 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/Examples/test-suite/java/special_variable_macros_runme.java b/Examples/test-suite/java/special_variable_macros_runme.java index dee629666..d7f8070b3 100644 --- a/Examples/test-suite/java/special_variable_macros_runme.java +++ b/Examples/test-suite/java/special_variable_macros_runme.java @@ -24,6 +24,8 @@ public class special_variable_macros_runme { 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/Examples/test-suite/python/special_variable_macros_runme.py b/Examples/test-suite/python/special_variable_macros_runme.py index a1d3308ed..07e60dfa2 100644 --- a/Examples/test-suite/python/special_variable_macros_runme.py +++ b/Examples/test-suite/python/special_variable_macros_runme.py @@ -11,4 +11,6 @@ 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/Examples/test-suite/special_variable_macros.i b/Examples/test-suite/special_variable_macros.i index 85adf7af1..3f0cd724a 100644 --- a/Examples/test-suite/special_variable_macros.i +++ b/Examples/test-suite/special_variable_macros.i @@ -110,6 +110,40 @@ const char * testJim(Name *jim, int count) { } %} +////////////////////////////////////////////////////////////////////////////////////// +// Template types with more than one template parameter + +// check $1 and $input get expanded properly when used from $typemap() +%typemap(in) Space::Pair PAIR_INT_BOOL ($1_type temp) +%{ + /*%typemap(in) Name *GENERIC start */ + temp = Space::Pair(123, true); + (void)$input; + $1 = ($1_ltype)temp; + /*%typemap(in) Name *GENERIC end */ +%} + +%typemap(in) Space::Pair john { +// %typemap(in) Name *john start +$typemap(in, Space::Pair PAIR_INT_BOOL) +// %typemap(in) Name *john end +} + +%inline %{ +namespace Space { + template struct Pair { + Pair(T1 f, T2 s) : first(f), second(s) {} + Pair() {} + T1 first; + T2 second; + }; + int testJohn(Space::Pair john) { + return john.first; + } +} +%} +%template(PairIntBool) Space::Pair; + ////////////////////////////////////////////////////////////////////////////////////// // A real use case for $typemap diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 0fae2344e..9fcbb38e0 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1699,9 +1699,10 @@ static List *split_embedded_typemap(String *s) { List *args = 0; char *c, *start; int level = 0; + int angle_level = 0; int leading = 1; - args = NewList(); + args = NewList(); c = strchr(Char(s), '('); assert(c); c++; @@ -1720,7 +1721,7 @@ static List *split_embedded_typemap(String *s) { c++; } } - if ((level == 0) && ((*c == ',') || (*c == ')'))) { + if ((level == 0) && angle_level == 0 && ((*c == ',') || (*c == ')'))) { String *tmp = NewStringWithSize(start, c - start); Append(args, tmp); Delete(tmp); @@ -1735,6 +1736,10 @@ static List *split_embedded_typemap(String *s) { level++; if (*c == ')') level--; + if (*c == '<') + angle_level++; + if (*c == '>') + angle_level--; if (isspace((int) *c) && leading) start++; if (!isspace((int) *c)) @@ -1901,6 +1906,7 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper } Delete(l); } + if (syntax_error) { String *dtypemap = NewString(dollar_typemap); Replaceall(dtypemap, "$TYPEMAP", "$typemap"); From b9ff3b0faeba2a7e607f25bc36509e3a86d2d154 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 Aug 2009 21:47:46 +0000 Subject: [PATCH 086/352] only display debug info when debug flag set git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11507 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/typemap_out_optimal.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/typemap_out_optimal.i b/Examples/test-suite/typemap_out_optimal.i index 8bac2fa89..23cd2ad3f 100644 --- a/Examples/test-suite/typemap_out_optimal.i +++ b/Examples/test-suite/typemap_out_optimal.i @@ -23,10 +23,10 @@ using namespace std; struct XX { - XX() { cout << "XX()" << endl; } + XX() { if (debug) cout << "XX()" << endl; } XX(int i) { if (debug) cout << "XX(" << i << ")" << endl; } - XX(const XX &other) { cout << "XX(const XX &)" << endl; } - XX& operator =(const XX &other) { cout << "operator=(const XX &)" << endl; return *this; } + XX(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); From 22c0b83cef8812fcf13b0021beaf1bd8ad090fec Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 Aug 2009 22:17:06 +0000 Subject: [PATCH 087/352] fix vector of templated types git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11508 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/tcl/std_vector.i | 78 ++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/Lib/tcl/std_vector.i b/Lib/tcl/std_vector.i index d913f00cc..273214292 100644 --- a/Lib/tcl/std_vector.i +++ b/Lib/tcl/std_vector.i @@ -16,17 +16,17 @@ // const declarations are used to guess the intent of the function being // exported; therefore, the following rationale is applied: // -// -- f(std::vector), f(const std::vector&), f(const std::vector*): +// -- f(std::vector< T >), f(const std::vector< T >&), f(const std::vector< T >*): // the parameter being read-only, either a Tcl list or a -// previously wrapped std::vector can be passed. -// -- f(std::vector&), f(std::vector*): +// previously wrapped std::vector< T > can be passed. +// -- f(std::vector< T >&), f(std::vector< T >*): // the parameter must be modified; therefore, only a wrapped std::vector // can be passed. -// -- std::vector f(): +// -- std::vector< T > f(): // the vector is returned by copy; therefore, a Tcl list of T:s // is returned which is most easily used in other Tcl functions procs -// -- std::vector& f(), std::vector* f(), const std::vector& f(), -// const std::vector* f(): +// -- std::vector< T >& f(), std::vector< T >* f(), const std::vector< T >& f(), +// const std::vector< T >* f(): // the vector is returned by reference; therefore, a wrapped std::vector // is returned // ------------------------------------------------------------------------ @@ -85,7 +85,7 @@ int SwigDouble_As(Tcl_Interp *interp, Tcl_Obj *o, Type *val) { namespace std { template class vector { - %typemap(in) vector (std::vector *v) { + %typemap(in) vector< T > (std::vector< T > *v) { Tcl_Obj **listobjv; int nitems; int i; @@ -95,11 +95,11 @@ namespace std { $&1_descriptor, 0) == 0){ $1 = *v; } else { - // It isn't a vector so it should be a list of T's + // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, \ &nitems, &listobjv) == TCL_ERROR) return TCL_ERROR; - $1 = std::vector(); + $1 = std::vector< T >(); for (i = 0; i < nitems; i++) { if ((SWIG_ConvertPtr(listobjv[i],(void **) &temp, $descriptor(T *),0)) != 0) { @@ -113,8 +113,8 @@ namespace std { } } - %typemap(in) const vector* (std::vector *v, std::vector w), - const vector& (std::vector *v, std::vector w) { + %typemap(in) const vector< T >* (std::vector< T > *v, std::vector< T > w), + const vector< T >& (std::vector< T > *v, std::vector< T > w) { Tcl_Obj **listobjv; int nitems; int i; @@ -124,11 +124,11 @@ namespace std { $&1_descriptor, 0) == 0) { $1 = v; } else { - // It isn't a vector so it should be a list of T's + // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) return TCL_ERROR; - w = std::vector(); + w = std::vector< T >(); for (i = 0; i < nitems; i++) { if ((SWIG_ConvertPtr(listobjv[i],(void **) &temp, $descriptor(T *),0)) != 0) { @@ -143,7 +143,7 @@ namespace std { } } - %typemap(out) vector { + %typemap(out) vector< T > { for (unsigned int i=0; i<$1.size(); i++) { T* ptr = new T((($1_type &)$1)[i]); Tcl_ListObjAppendElement(interp, $result, \ @@ -153,18 +153,18 @@ namespace std { } } - %typecheck(SWIG_TYPECHECK_VECTOR) vector { + %typecheck(SWIG_TYPECHECK_VECTOR) vector< T > { Tcl_Obj **listobjv; int nitems; T* temp; - std::vector *v; + std::vector< T > *v; if(SWIG_ConvertPtr($input, (void **) &v, \ $&1_descriptor, 0) == 0) { /* wrapped vector */ $1 = 1; } else { - // It isn't a vector so it should be a list of T's + // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) $1 = 0; @@ -181,19 +181,19 @@ namespace std { } } - %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, - const vector* { + %typecheck(SWIG_TYPECHECK_VECTOR) const vector< T >&, + const vector< T >* { Tcl_Obj **listobjv; int nitems; T* temp; - std::vector *v; + std::vector< T > *v; if(SWIG_ConvertPtr($input, (void **) &v, \ $1_descriptor, 0) == 0){ /* wrapped vector */ $1 = 1; } else { - // It isn't a vector so it should be a list of T's + // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) $1 = 0; @@ -213,7 +213,7 @@ namespace std { public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector &); + vector(const vector< T > &); unsigned int size() const; bool empty() const; @@ -251,9 +251,9 @@ namespace std { // specializations for built-ins %define specialize_std_vector(T, CONVERT_FROM, CONVERT_TO) - template<> class vector { + template<> class vector< T > { - %typemap(in) vector (std::vector *v){ + %typemap(in) vector< T > (std::vector< T > *v){ Tcl_Obj **listobjv; int nitems; int i; @@ -263,11 +263,11 @@ namespace std { $&1_descriptor, 0) == 0) { $1 = *v; } else { - // It isn't a vector so it should be a list of T's + // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) return TCL_ERROR; - $1 = std::vector(); + $1 = std::vector< T >(); for (i = 0; i < nitems; i++) { if (CONVERT_FROM(interp, listobjv[i], &temp) == TCL_ERROR) return TCL_ERROR; @@ -276,8 +276,8 @@ namespace std { } } - %typemap(in) const vector& (std::vector *v,std::vector w), - const vector* (std::vector *v,std::vector w) { + %typemap(in) const vector< T >& (std::vector< T > *v,std::vector< T > w), + const vector< T >* (std::vector< T > *v,std::vector< T > w) { Tcl_Obj **listobjv; int nitems; int i; @@ -287,11 +287,11 @@ namespace std { $1_descriptor, 0) == 0) { $1 = v; } else { - // It isn't a vector so it should be a list of T's + // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) return TCL_ERROR; - w = std::vector(); + w = std::vector< T >(); for (i = 0; i < nitems; i++) { if (CONVERT_FROM(interp, listobjv[i], &temp) == TCL_ERROR) return TCL_ERROR; @@ -301,25 +301,25 @@ namespace std { } } - %typemap(out) vector { + %typemap(out) vector< T > { for (unsigned int i=0; i<$1.size(); i++) { Tcl_ListObjAppendElement(interp, $result, \ CONVERT_TO((($1_type &)$1)[i])); } } - %typecheck(SWIG_TYPECHECK_VECTOR) vector { + %typecheck(SWIG_TYPECHECK_VECTOR) vector< T > { Tcl_Obj **listobjv; int nitems; T temp; - std::vector *v; + std::vector< T > *v; if(SWIG_ConvertPtr($input, (void **) &v, \ $&1_descriptor, 0) == 0){ /* wrapped vector */ $1 = 1; } else { - // It isn't a vector so it should be a list of T's + // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) $1 = 0; @@ -334,19 +334,19 @@ namespace std { } } - %typecheck(SWIG_TYPECHECK_VECTOR) const vector&, - const vector*{ + %typecheck(SWIG_TYPECHECK_VECTOR) const vector< T >&, + const vector< T >*{ Tcl_Obj **listobjv; int nitems; T temp; - std::vector *v; + std::vector< T > *v; if(SWIG_ConvertPtr($input, (void **) &v, \ $1_descriptor, 0) == 0){ /* wrapped vector */ $1 = 1; } else { - // It isn't a vector so it should be a list of T's + // It isn't a vector< T > so it should be a list of T's if(Tcl_ListObjGetElements(interp, $input, &nitems, &listobjv) == TCL_ERROR) $1 = 0; @@ -364,7 +364,7 @@ namespace std { public: vector(unsigned int size = 0); vector(unsigned int size, const T& value); - vector(const vector &); + vector(const vector< T > &); unsigned int size() const; bool empty() const; From 77096c878b0c4ca13ad06211bb54c2df70064c69 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 5 Aug 2009 22:19:04 +0000 Subject: [PATCH 088/352] add a new testcase testing combinations of STL types... just vector and pair at the moment git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11509 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + Examples/test-suite/li_std_combinations.i | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 Examples/test-suite/li_std_combinations.i diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 56097abd9..9987f3c0f 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -405,6 +405,7 @@ CPP_TEST_CASES += \ CPP_STD_TEST_CASES += \ director_string \ ignore_template_constructor \ + li_std_combinations \ li_std_deque \ li_std_except \ li_std_pair \ diff --git a/Examples/test-suite/li_std_combinations.i b/Examples/test-suite/li_std_combinations.i new file mode 100644 index 000000000..d760fa44e --- /dev/null +++ b/Examples/test-suite/li_std_combinations.i @@ -0,0 +1,15 @@ +%module li_std_combinations + +%include +%include +%include + +%template(VectorInt) std::vector; +%template(VectorString) std::vector; +%template(PairIntString) std::pair; + +%template(VectorPairIntString) std::vector< std::pair >; +%template(PairIntVectorString) std::pair< int, std::vector >; + +%template(VectorVectorString) std::vector< std::vector >; +%template(PairIntPairIntString) std::pair< int, std::pair >; From 09b20003fb02553252e6e80d6183c72311cbcc60 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 6 Aug 2009 12:27:03 +0000 Subject: [PATCH 089/352] PHP: fix for the overload_rename testcase Previously we just had two __construct function which resulted in a parse error. Now we create a new factory method for the renamed ctor. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11510 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/php/overload_rename_runme.php | 19 +++++++++++++++++++ Source/Modules/php.cxx | 14 ++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 Examples/test-suite/php/overload_rename_runme.php diff --git a/Examples/test-suite/php/overload_rename_runme.php b/Examples/test-suite/php/overload_rename_runme.php new file mode 100644 index 000000000..dce4c6cb3 --- /dev/null +++ b/Examples/test-suite/php/overload_rename_runme.php @@ -0,0 +1,19 @@ + diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 0591d971c..84024eac1 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1026,7 +1026,13 @@ public: String *output = s_oowrappers; if (constructor) { class_has_ctor = true; - methodname = "__construct"; + if (strcmp(GetChar(n, "name"), GetChar(n, "constructorHandler:sym:name")) == 0) { + methodname = "__construct"; + } else { + // The class has multiple constructors and this one is + // renamed, so this will be a static factory function + methodname = GetChar(n, "constructorHandler:sym:name"); + } } else if (wrapperType == memberfn) { methodname = Char(Getattr(n, "memberfunctionHandler:sym:name")); } else if (wrapperType == staticmemberfn) { @@ -1585,7 +1591,11 @@ public: Printf(output, "%s", prepare); if (constructor) { if (!directorsEnabled() || !Swig_directorclass(n)) { - Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke); + if (strcmp(methodname, "__construct") == 0) { + Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke); + } else { + Printf(output, "\t\treturn new %s(%s);\n", "Foo", invoke); + } } else { Node *parent = Swig_methodclass(n); String *classname = Swig_class_name(parent); From 486419b27134323d5f8e60998ca933926db2e965 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 6 Aug 2009 13:16:50 +0000 Subject: [PATCH 090/352] PHP: Skip the Foo:: prefix when detecting ctor renames This fixes a few testcases (like the mixed_types one) I broke in the previous commit. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11512 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 84024eac1..849ba043b 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1026,7 +1026,14 @@ public: String *output = s_oowrappers; if (constructor) { class_has_ctor = true; - if (strcmp(GetChar(n, "name"), GetChar(n, "constructorHandler:sym:name")) == 0) { + // Skip the Foo:: prefix. + char *ptr = strrchr(GetChar(n, "name"), ':'); + if (ptr) { + ptr++; + } else { + ptr = GetChar(n, "name"); + } + if (strcmp(ptr, GetChar(n, "constructorHandler:sym:name")) == 0) { methodname = "__construct"; } else { // The class has multiple constructors and this one is From 9d5b0d7bf4a97306de7675cf09a45b0508ed69ca Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 6 Aug 2009 19:57:55 +0000 Subject: [PATCH 091/352] Python: cleanup in the template_typedef_import testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11513 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/template_typedef_import_runme.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Examples/test-suite/python/template_typedef_import_runme.py b/Examples/test-suite/python/template_typedef_import_runme.py index 48d88eda0..5c0b0b936 100644 --- a/Examples/test-suite/python/template_typedef_import_runme.py +++ b/Examples/test-suite/python/template_typedef_import_runme.py @@ -1,4 +1,3 @@ -import string from template_typedef_cplx2 import * from template_typedef_import import * From 60e20c6ec5a980d2363b0621f91a2a5dff4a095d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 7 Aug 2009 21:50:21 +0000 Subject: [PATCH 092/352] fix %valuewrapper macro git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11514 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/swig.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/swig.swg b/Lib/swig.swg index 77308e080..c0ecad9dd 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -152,7 +152,7 @@ #define %clearnaturalvar %feature("naturalvar","") /* valuewrapper directives */ -#define %valuewrapper %feature("valuewrapper",) +#define %valuewrapper %feature("valuewrapper") #define %clearvaluewrapper %feature("valuewrapper","") #define %novaluewrapper %feature("novaluewrapper") #define %clearnovaluewrapper %feature("novaluewrapper","") From 136bd5175af2864ac32ded708e3f0ba7c249ed66 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 8 Aug 2009 22:56:10 +0000 Subject: [PATCH 093/352] Python and Tcl - improve error message for missing constructor when the reason is because the class is abstract. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11518 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 10 ++++++++++ Source/Modules/python.cxx | 2 +- Source/Modules/tcl8.cxx | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index e403c1b60..e3f690daa 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,16 @@ Version 1.3.40 (in progress) ============================ +2009-08-08: wsfulton + [Python] More user friendly AttributeError is raised when there are + no constructors generated for the proxy class in the event that the + class is abstract - the error message is now + "No constructor defined - class is abstract" whereas if there are no + public constructors for any other reason and the class is not abstract, + the message remains + "No constructor defined". + [tcl] Similarly for tcl when using -itcl. + 2009-08-04: olly [PHP] Fix generated code to work with PHP 5.3. diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 5ae98407b..9475139a3 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2984,7 +2984,7 @@ public: Delete(realct); } if (!have_constructor) { - Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"No constructor defined\")\n", NIL); + Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"", "No constructor defined", (Getattr(n, "abstract") ? " - class is abstract" : ""), "\")\n", NIL); } else if (fastinit) { Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 015ac5e45..ef6b3109e 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -931,13 +931,13 @@ public: Printv(f_shadow, " constructor { } {\n", NIL); Printv(f_shadow, " # This constructor will fail if called directly\n", NIL); Printv(f_shadow, " if { [info class] == \"::", class_name, "\" } {\n", NIL); - Printv(f_shadow, " error \"No constructor for class ", class_name, "\"\n", NIL); + Printv(f_shadow, " error \"No constructor for class ", class_name, (Getattr(n, "abstract") ? " - class is abstract" : ""), "\"\n", NIL); Printv(f_shadow, " }\n", NIL); Printv(f_shadow, " }\n", NIL); } Printv(f_shadow, "}\n\n", NIL); - }; + } Printv(f_wrappers, "static swig_class *swig_", mangled_classname, "_bases[] = {", base_class, "0};\n", NIL); Printv(f_wrappers, "static const char * swig_", mangled_classname, "_base_names[] = {", base_class_names, "0};\n", NIL); From 46a258a748dd56d5a04fb3614ee28a27869060c7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 8 Aug 2009 23:29:08 +0000 Subject: [PATCH 094/352] Add another common cause for getting an UnsatisfiedLinkError git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11519 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Java.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 2cde5ddab..fc5646c10 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -447,6 +447,19 @@ $

      This error usually indicates that you forgot to include some object files or libraries in the linking of the native library file. Make sure you compile both the SWIG wrapper file and the code you are wrapping into the native library file. +If you forget to compile and link in the SWIG wrapper file into your native library file, you will get a message similar to the following: +

      + +
      +$ java runme
      +Exception in thread "main" java.lang.UnsatisfiedLinkError: exampleJNI.gcd(II)I
      +	at exampleJNI.gcd(Native Method)
      +	at example.gcd(example.java:12)
      +	at runme.main(runme.java:18)
      +
      + +

      +where gcd is the missing JNI function that SWIG generated into the wrapper file. Also make sure you pass all of the required libraries to the linker. The java -verbose:jni commandline switch is also a great way to get more information on unresolved symbols. One last piece of advice is to beware of the common faux pas of having more than one native library version in your path. From e2f2a7c128d41d3d5eaf0175d00fcc935c426a78 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 9 Aug 2009 13:13:21 +0000 Subject: [PATCH 095/352] Avoid dereferencing a NULL pointer in the constant_pointers testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11520 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/constant_pointers.i | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i index 5bd2fd533..c2344fb6a 100644 --- a/Examples/test-suite/constant_pointers.i +++ b/Examples/test-suite/constant_pointers.i @@ -121,7 +121,8 @@ int* const globalRet2() {return &GlobalInt;} %{ static int wxEVT_COMMAND_BUTTON_CLICKEDv; -static int **wxEVT_COMMAND_BUTTON_CLICKEDp; +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 @@ -137,7 +138,7 @@ char *langs[] ={ lang1 }; #define EWXWEXPORT_VAR const int* wxEVENT_COMMAND_BUTTON_CLICKEDr = (int*) &wxEVT_COMMAND_BUTTON_CLICKEDv; - const int* wxEVENT_COMMAND_BUTTON_CLICKEDp = (int*) *wxEVT_COMMAND_BUTTON_CLICKEDp; + const int* wxEVENT_COMMAND_BUTTON_CLICKEDp = (int*) *wxEVT_COMMAND_BUTTON_CLICKEDpp; char **languages1 = &langs[0]; char **languages2 = (char **)&langs[0]; } From d5e546f07f5e7570f9ed73739da068f2ed16784d Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 9 Aug 2009 14:51:22 +0000 Subject: [PATCH 096/352] PHP: Run testcase.php if testcase_runme.php is not found in the testsuite git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11521 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/Makefile.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index ae1b78bf8..b52350259 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -44,11 +44,13 @@ missingtests: missingcpptests missingctests +$(swig_and_compile_multi_cpp) +$(run_testcase) -# Runs the testcase. A testcase is only run if -# a file is found which has _runme.php appended after the testcase name. +# 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 From 56c5b52c1d2c0bb05a349e6a94bef4e51ba26a61 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 9 Aug 2009 22:39:51 +0000 Subject: [PATCH 097/352] remove unnecessary extra shells being spawned in the test-suite git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11522 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 2 +- Examples/test-suite/allegrocl/Makefile.in | 4 ++-- Examples/test-suite/cffi/Makefile.in | 4 ++-- Examples/test-suite/chicken/Makefile.in | 16 ++++++++-------- Examples/test-suite/clisp/Makefile.in | 4 ++-- Examples/test-suite/csharp/Makefile.in | 12 ++++++------ Examples/test-suite/guile/Makefile.in | 4 ++-- Examples/test-suite/guilescm/Makefile.in | 8 ++++---- Examples/test-suite/java/Makefile.in | 12 ++++++------ Examples/test-suite/lua/Makefile.in | 4 ++-- Examples/test-suite/mzscheme/Makefile.in | 4 ++-- Examples/test-suite/ocaml/Makefile.in | 8 ++++---- Examples/test-suite/octave/Makefile.in | 4 ++-- Examples/test-suite/perl5/Makefile.in | 4 ++-- Examples/test-suite/php/Makefile.in | 8 ++++---- Examples/test-suite/pike/Makefile.in | 4 ++-- Examples/test-suite/python/Makefile.in | 15 +++++++-------- Examples/test-suite/r/Makefile.in | 17 ++++++++--------- Examples/test-suite/ruby/Makefile.in | 4 ++-- Examples/test-suite/tcl/Makefile.in | 4 ++-- Examples/test-suite/uffi/Makefile.in | 4 ++-- 21 files changed, 72 insertions(+), 74 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 8fab7a25d..6fbececfd 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -318,7 +318,7 @@ 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; + if [ -f runme.py ]; then rm -f runme3.py runme3.py.bak; fi; ################################################################## diff --git a/Examples/test-suite/allegrocl/Makefile.in b/Examples/test-suite/allegrocl/Makefile.in index 556c38238..b5576a6e0 100644 --- a/Examples/test-suite/allegrocl/Makefile.in +++ b/Examples/test-suite/allegrocl/Makefile.in @@ -114,8 +114,8 @@ include $(srcdir)/../common.mk # 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);) \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi; %.clean: diff --git a/Examples/test-suite/cffi/Makefile.in b/Examples/test-suite/cffi/Makefile.in index ac24688e3..034681105 100644 --- a/Examples/test-suite/cffi/Makefile.in +++ b/Examples/test-suite/cffi/Makefile.in @@ -38,8 +38,8 @@ CPP_TEST_CASES = # 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);) \ + 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) diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in index c5cbd827d..970e9902f 100644 --- a/Examples/test-suite/chicken/Makefile.in +++ b/Examples/test-suite/chicken/Makefile.in @@ -43,24 +43,24 @@ SWIGOPT += -nounit $(setup) +$(swig_and_compile_cpp) $(run_testcase) - if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then ( \ - $(MAKE) $*.cppproxy; ) \ + 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; ) \ + 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; ) \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \ + $(MAKE) $*.multiproxy; \ fi; %.externaltest: @@ -86,8 +86,8 @@ SWIGOPT += -nounit # 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);) \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi; # Clean diff --git a/Examples/test-suite/clisp/Makefile.in b/Examples/test-suite/clisp/Makefile.in index 2139faaed..b519aaf26 100644 --- a/Examples/test-suite/clisp/Makefile.in +++ b/Examples/test-suite/clisp/Makefile.in @@ -38,8 +38,8 @@ CPP_TEST_CASES = # 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);) \ + 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) diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index ae6f2c113..1b9e07e7a 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -59,30 +59,30 @@ setup = \ echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \ fi; \ if [ ! -d $* ]; then \ - mkdir $*; \ + 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 ( \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \ CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` \ $*$(CSHARPPATHSEPARATOR)*.cs' csharp_compile && \ - env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; ) \ - else ( \ + 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='*.cs' csharp_compile; ); \ + CSHARPSRCS='*.cs' csharp_compile && cd .. ; \ fi; # Clean: remove testcase directories %.clean: @if [ -d $* ]; then \ - rm -rf $*; \ + rm -rf $*; \ fi; clean: diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in index afea6a850..92e3cf1f2 100644 --- a/Examples/test-suite/guile/Makefile.in +++ b/Examples/test-suite/guile/Makefile.in @@ -44,8 +44,8 @@ include $(srcdir)/../common.mk # 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);) \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi; # Clean diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in index 854b1ac7f..cc298af07 100644 --- a/Examples/test-suite/guilescm/Makefile.in +++ b/Examples/test-suite/guilescm/Makefile.in @@ -19,8 +19,8 @@ GUILE_RUNTIME= # 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);) \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi; setup = \ @@ -44,6 +44,6 @@ local_setup = \ fi; local_run_testcase = \ - if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then ( \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$*$(SCRIPTSUFFIX);) \ + if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$*$(SCRIPTSUFFIX); \ fi; diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 8d4fbb546..bba7a90ca 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -67,23 +67,23 @@ setup = \ echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \ fi; \ if [ ! -d $* ]; then \ - mkdir $*; \ + mkdir $*; \ fi; # Compiles java files then runs the testcase. A testcase is only run if # a file is found which has _runme.java appended after the testcase name. # Note Java uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows, SHLIB_PATH on HPUX and DYLD_LIBRARY_PATH on Mac OS X. run_testcase = \ - (cd $* && $(COMPILETOOL) $(JAVAC) -classpath . *.java) && \ - if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ - $(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme;) \ + cd $* && $(COMPILETOOL) $(JAVAC) -classpath . *.java && cd .. && \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ + $(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ + env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme; \ fi; # Clean: remove testcase directories %.clean: @if [ -d $* ]; then \ - rm -rf $*; \ + rm -rf $*; \ fi; clean: diff --git a/Examples/test-suite/lua/Makefile.in b/Examples/test-suite/lua/Makefile.in index d48a7c43b..f0f4714f3 100644 --- a/Examples/test-suite/lua/Makefile.in +++ b/Examples/test-suite/lua/Makefile.in @@ -46,8 +46,8 @@ LIBS = -L. # 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);) \ + 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) diff --git a/Examples/test-suite/mzscheme/Makefile.in b/Examples/test-suite/mzscheme/Makefile.in index 7674dbee0..79dd9a8dc 100644 --- a/Examples/test-suite/mzscheme/Makefile.in +++ b/Examples/test-suite/mzscheme/Makefile.in @@ -36,8 +36,8 @@ include $(srcdir)/../common.mk # 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);) \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(MZSCHEME) -r $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi; # Clean diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 4a7e363a7..f16c3da95 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -14,13 +14,13 @@ C_TEST_CASES = run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \ - -f $(top_srcdir)/Examples/test-suite/$*.list ] ; then ( \ + -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) 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) ; \ + $(RUNTOOL) ./runme; \ fi ; check_quant: diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index 202adbbb8..7f4015324 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -56,8 +56,8 @@ LIBS = -L. # 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);) \ + 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 diff --git a/Examples/test-suite/perl5/Makefile.in b/Examples/test-suite/perl5/Makefile.in index d9862abfe..6620bcaa4 100644 --- a/Examples/test-suite/perl5/Makefile.in +++ b/Examples/test-suite/perl5/Makefile.in @@ -49,8 +49,8 @@ include $(srcdir)/../common.mk # 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) ; ) \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PERL) $(TEST_RUNNER) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi; \ diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index b52350259..de153808b 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -47,10 +47,10 @@ missingtests: missingcpptests missingctests # 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;) \ + 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 diff --git a/Examples/test-suite/pike/Makefile.in b/Examples/test-suite/pike/Makefile.in index 1a61086b6..338c3a6e0 100644 --- a/Examples/test-suite/pike/Makefile.in +++ b/Examples/test-suite/pike/Makefile.in @@ -36,8 +36,8 @@ include $(srcdir)/../common.mk # 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);) \ + 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 diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index cf1f80389..4c6c88c94 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -125,16 +125,15 @@ py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) ifeq (,$(PY3)) run_testcase = \ - if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ - $(run_python);)\ + 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);) \ + if [ -f $(py2_runme) ]; then \ + $(MAKE) -f $(srcdir)/Makefile $(py3_runme) && $(run_python); \ + elif [ -f $(py3_runme) ]; then \ + $(run_python); \ fi; endif @@ -143,7 +142,7 @@ endif @rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py @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; + @if [ -f $(py2_runme) ]; then rm -f $(py3_runme) $(py3_runme).bak; fi; clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 242588640..2fefa3e0b 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -42,20 +42,19 @@ include $(srcdir)/../common.mk # 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) ;) \ + 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);) \ + $(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 ( \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" \ - $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX) ;) \ + $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(SCRIPTSUFFIX); \ else \ - ($(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX);) \ + $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$${f}$(WRAPSUFFIX); \ fi; \ done # Clean @@ -64,10 +63,10 @@ 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 ( \ + @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 ) \ + done \ fi diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index e1d7e7889..8265e2653 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -60,8 +60,8 @@ ruby_naming.cpptest: SWIGOPT += -autorename # 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);) \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi; # Clean diff --git a/Examples/test-suite/tcl/Makefile.in b/Examples/test-suite/tcl/Makefile.in index bac2ae756..34a57d229 100644 --- a/Examples/test-suite/tcl/Makefile.in +++ b/Examples/test-suite/tcl/Makefile.in @@ -45,8 +45,8 @@ include $(srcdir)/../common.mk # 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);) \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(TCLSH) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ fi; # Clean diff --git a/Examples/test-suite/uffi/Makefile.in b/Examples/test-suite/uffi/Makefile.in index 4a45c1c6e..663981961 100644 --- a/Examples/test-suite/uffi/Makefile.in +++ b/Examples/test-suite/uffi/Makefile.in @@ -38,8 +38,8 @@ CPP_TEST_CASES = # 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);) \ + 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) From 451f71d7b16ccfd420f2ff78762818fe4ec81f5b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 9 Aug 2009 22:52:08 +0000 Subject: [PATCH 098/352] remove unnecessary extra semicolons in the tesuite Basically just style cleanup, "fi;" or "fi; \" -> "fi". git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11523 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 2 +- Examples/test-suite/allegrocl/Makefile.in | 2 +- Examples/test-suite/cffi/Makefile.in | 2 +- Examples/test-suite/chicken/Makefile.in | 8 ++++---- Examples/test-suite/clisp/Makefile.in | 2 +- Examples/test-suite/csharp/Makefile.in | 6 +++--- Examples/test-suite/guile/Makefile.in | 2 +- Examples/test-suite/guilescm/Makefile.in | 8 ++++---- Examples/test-suite/java/Makefile.in | 6 +++--- Examples/test-suite/lua/Makefile.in | 2 +- Examples/test-suite/mzscheme/Makefile.in | 2 +- Examples/test-suite/octave/Makefile.in | 2 +- Examples/test-suite/perl5/Makefile.in | 3 +-- Examples/test-suite/php/Makefile.in | 2 +- Examples/test-suite/pike/Makefile.in | 2 +- Examples/test-suite/python/Makefile.in | 6 +++--- Examples/test-suite/r/Makefile.in | 2 +- Examples/test-suite/ruby/Makefile.in | 2 +- Examples/test-suite/tcl/Makefile.in | 2 +- Examples/test-suite/uffi/Makefile.in | 2 +- Makefile.in | 2 +- 21 files changed, 33 insertions(+), 34 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 6fbececfd..16f3cfbe2 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -318,7 +318,7 @@ 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; + if [ -f runme.py ]; then rm -f runme3.py runme3.py.bak; fi ################################################################## diff --git a/Examples/test-suite/allegrocl/Makefile.in b/Examples/test-suite/allegrocl/Makefile.in index b5576a6e0..5f75bfc08 100644 --- a/Examples/test-suite/allegrocl/Makefile.in +++ b/Examples/test-suite/allegrocl/Makefile.in @@ -116,7 +116,7 @@ include $(srcdir)/../common.mk run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + fi %.clean: @rm -f $*.cl diff --git a/Examples/test-suite/cffi/Makefile.in b/Examples/test-suite/cffi/Makefile.in index 034681105..bf21b3552 100644 --- a/Examples/test-suite/cffi/Makefile.in +++ b/Examples/test-suite/cffi/Makefile.in @@ -40,7 +40,7 @@ CPP_TEST_CASES = run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + fi # Clean: (does nothing, we dont generate extra cffi code) %.clean: diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in index 970e9902f..42fe6100a 100644 --- a/Examples/test-suite/chicken/Makefile.in +++ b/Examples/test-suite/chicken/Makefile.in @@ -45,7 +45,7 @@ SWIGOPT += -nounit $(run_testcase) if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \ $(MAKE) $*.cppproxy; \ - fi; + fi %.ctest: $(setup) @@ -53,7 +53,7 @@ SWIGOPT += -nounit $(run_testcase) if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \ $(MAKE) $*.cproxy; \ - fi; + fi %.multicpptest: $(setup) @@ -61,7 +61,7 @@ SWIGOPT += -nounit $(run_testcase) if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(PROXYSUFFIX) ]; then \ $(MAKE) $*.multiproxy; \ - fi; + fi %.externaltest: $(setup) @@ -88,7 +88,7 @@ SWIGOPT += -nounit run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CHICKEN_CSI) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + fi # Clean %.clean: diff --git a/Examples/test-suite/clisp/Makefile.in b/Examples/test-suite/clisp/Makefile.in index b519aaf26..2ebaa6750 100644 --- a/Examples/test-suite/clisp/Makefile.in +++ b/Examples/test-suite/clisp/Makefile.in @@ -40,7 +40,7 @@ CPP_TEST_CASES = run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(CLISPBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + fi # Clean: (does nothing, we dont generate extra clisp code) %.clean: diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 1b9e07e7a..1545eb30d 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -60,7 +60,7 @@ setup = \ fi; \ if [ ! -d $* ]; then \ mkdir $*; \ - fi; + 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. @@ -77,13 +77,13 @@ run_testcase = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \ CSHARPSRCS='*.cs' csharp_compile && cd .. ; \ - fi; + fi # Clean: remove testcase directories %.clean: @if [ -d $* ]; then \ rm -rf $*; \ - fi; + fi clean: @rm -f *.exe *.exe.mdb diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in index 92e3cf1f2..c6be92c32 100644 --- a/Examples/test-suite/guile/Makefile.in +++ b/Examples/test-suite/guile/Makefile.in @@ -46,7 +46,7 @@ include $(srcdir)/../common.mk run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + fi # Clean %.clean: diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in index cc298af07..ba1cba440 100644 --- a/Examples/test-suite/guilescm/Makefile.in +++ b/Examples/test-suite/guilescm/Makefile.in @@ -21,14 +21,14 @@ GUILE_RUNTIME= run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + 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; + fi %.externaltest: $(local_setup) @@ -41,9 +41,9 @@ local_setup = \ echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE) (with SCM API)" ; \ else \ echo "$(ACTION)ing testcase $* under $(LANGUAGE) (with SCM API)" ; \ - fi; + fi local_run_testcase = \ if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(GUILE) -l $(srcdir)/$*$(SCRIPTSUFFIX); \ - fi; + fi diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index bba7a90ca..5c96ca154 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -68,7 +68,7 @@ setup = \ fi; \ if [ ! -d $* ]; then \ mkdir $*; \ - fi; + 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. @@ -78,13 +78,13 @@ run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme; \ - fi; + fi # Clean: remove testcase directories %.clean: @if [ -d $* ]; then \ rm -rf $*; \ - fi; + fi clean: @rm -f *.class hs_err*.log diff --git a/Examples/test-suite/lua/Makefile.in b/Examples/test-suite/lua/Makefile.in index f0f4714f3..0ddc86a7d 100644 --- a/Examples/test-suite/lua/Makefile.in +++ b/Examples/test-suite/lua/Makefile.in @@ -48,7 +48,7 @@ LIBS = -L. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + fi # Clean: (does nothing, we dont generate extra lua code) %.clean: diff --git a/Examples/test-suite/mzscheme/Makefile.in b/Examples/test-suite/mzscheme/Makefile.in index 79dd9a8dc..fcaf33a48 100644 --- a/Examples/test-suite/mzscheme/Makefile.in +++ b/Examples/test-suite/mzscheme/Makefile.in @@ -38,7 +38,7 @@ include $(srcdir)/../common.mk run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(MZSCHEME) -r $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + fi # Clean %.clean: diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index 7f4015324..70de84adc 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -58,7 +58,7 @@ LIBS = -L. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVEPATH=$(srcdir):OCTAVEPATH $(RUNTOOL) $(OCTAVE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + fi # Clean: remove the generated .m file %.clean: diff --git a/Examples/test-suite/perl5/Makefile.in b/Examples/test-suite/perl5/Makefile.in index 6620bcaa4..67eaf5c9a 100644 --- a/Examples/test-suite/perl5/Makefile.in +++ b/Examples/test-suite/perl5/Makefile.in @@ -51,8 +51,7 @@ include $(srcdir)/../common.mk run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PERL) $(TEST_RUNNER) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; \ - + fi # Clean: remove the generated .pm file %.clean: diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in index de153808b..963051258 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php/Makefile.in @@ -51,7 +51,7 @@ run_testcase = \ $(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; + fi # Clean: remove the generated .php file %.clean: diff --git a/Examples/test-suite/pike/Makefile.in b/Examples/test-suite/pike/Makefile.in index 338c3a6e0..389dc74f8 100644 --- a/Examples/test-suite/pike/Makefile.in +++ b/Examples/test-suite/pike/Makefile.in @@ -38,7 +38,7 @@ include $(srcdir)/../common.mk run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PIKE) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + fi # Clean: remove the generated .pike file %.clean: diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 4c6c88c94..cfb02cf2d 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -127,14 +127,14 @@ ifeq (,$(PY3)) run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ $(run_python);\ - fi; + 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; + fi endif # Clean: remove the generated .py file @@ -142,7 +142,7 @@ endif @rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py @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; + @if [ -f $(py2_runme) ]; then rm -f $(py3_runme) $(py3_runme).bak; fi clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 2fefa3e0b..32d046679 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -46,7 +46,7 @@ run_testcase = \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PATH=.:"$$PATH" $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ else \ $(RUNTOOL) $(RUNR) $(srcdir)/$(SCRIPTPREFIX)$*$(WRAPSUFFIX); \ - fi; + fi run_multitestcase = \ for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \ diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 8265e2653..dc8751da1 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -62,7 +62,7 @@ ruby_naming.cpptest: SWIGOPT += -autorename run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + fi # Clean %.clean: diff --git a/Examples/test-suite/tcl/Makefile.in b/Examples/test-suite/tcl/Makefile.in index 34a57d229..49d2a7826 100644 --- a/Examples/test-suite/tcl/Makefile.in +++ b/Examples/test-suite/tcl/Makefile.in @@ -47,7 +47,7 @@ include $(srcdir)/../common.mk run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(TCLSH) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + fi # Clean %.clean: diff --git a/Examples/test-suite/uffi/Makefile.in b/Examples/test-suite/uffi/Makefile.in index 663981961..d6b948b5d 100644 --- a/Examples/test-suite/uffi/Makefile.in +++ b/Examples/test-suite/uffi/Makefile.in @@ -40,7 +40,7 @@ CPP_TEST_CASES = run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(UFFIBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - fi; + fi # Clean: (does nothing, we dont generate extra uffi code) %.clean: diff --git a/Makefile.in b/Makefile.in index 42fa935d6..ec8cdb8be 100644 --- a/Makefile.in +++ b/Makefile.in @@ -182,7 +182,7 @@ java.actionexample: else \ echo $(ACTION)ing Examples/$(LANGUAGE)/java; \ (cd Examples/$(LANGUAGE)/java && $(MAKE) -s $(chk-set-env) $(ACTION)) \ - fi; \ + fi gifplot-library: @echo $(ACTION)ing Examples/GIFPlot/Lib From 8615adfb07900c653d08a72acec22c791f0ae987 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 10 Aug 2009 21:58:54 +0000 Subject: [PATCH 099/352] Remove memory leak for char ** out typemap example, as per Peter Allen email on swig-user on, ahem, 19 July 2006 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11527 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Perl5.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 0579cddfd..8f74bd1de 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -2173,7 +2173,7 @@ reference to be used as a char ** datatype. }; myav = av_make(len,svs); free(svs); - $result = newRV((SV*)myav); + $result = newRV_noinc((SV*)myav); sv_2mortal($result); argvi++; } From b61f9da6e6eccbe1dbe2c469b48d5f80666dc017 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 11 Aug 2009 10:19:04 +0000 Subject: [PATCH 100/352] PHP: fix for the template_ref_type testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11528 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 849ba043b..366425382 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1194,7 +1194,7 @@ public: const char *pname_cstr = GetChar(p, "name"); // Just get rid of the C++ namespace part for now. const char *ptr = NULL; - if ((ptr = strrchr(pname_cstr, ':'))) { + if (pname_cstr && (ptr = strrchr(pname_cstr, ':'))) { pname_cstr = ptr + 1; } if (!pname_cstr) { From abcff1089d4f06eddabd27a03f3c1910a965d282 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 11 Aug 2009 13:56:50 +0000 Subject: [PATCH 101/352] Fix 2 of the 3 warnings under PHP (the remaining one doesn't seem to respond to %warnfilter as I'd expect...) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11529 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php_namewarn_rename.i | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/php_namewarn_rename.i b/Examples/test-suite/php_namewarn_rename.i index 87877c4f0..cebe93f02 100644 --- a/Examples/test-suite/php_namewarn_rename.i +++ b/Examples/test-suite/php_namewarn_rename.i @@ -1,20 +1,23 @@ %module php_namewarn_rename +#ifdef SWIGPHP +%warnfilter(SWIGWARN_PARSE_KEYWORD) Empty(); +// FIXME: this doesn't work for me: +%warnfilter(SWIGWARN_PARSE_KEYWORD) stdClass; +%warnfilter(SWIGWARN_PARSE_KEYWORD) Hello::empty(); +#endif %inline %{ - void Empty() {}; - + void Empty() {} - class stdClass + class stdClass { }; - struct Hello + struct Hello { - void empty() {} + void empty() {} }; - - %} From 37b9370344a737d6e216f597adf5a50d4dc898fd Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 11 Aug 2009 14:40:51 +0000 Subject: [PATCH 102/352] Eliminate space before "function" when there's no access specifier (just a cosmetic tweak). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11530 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 366425382..0ea23080f 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1570,6 +1570,9 @@ public: Delete(warnmsg); } } + if (Cmp(acc, "") != 0) { + Append(acc, " "); + } if (constructor) { const char * arg0; if (max_num_of_arguments > 0) { @@ -1581,13 +1584,13 @@ public: } SwigType *t = Getattr(current_class, "classtype"); String *mangled_type = SwigType_manglestr(SwigType_ltype(t)); - Printf(output, "\t%s function %s(%s) {\n", acc, methodname, args); + Printf(output, "\t%sfunction %s(%s) {\n", acc, methodname, args); Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '_p%s') {\n", arg0, arg0, mangled_type); Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0); Printf(output, "\t\t\treturn;\n"); Printf(output, "\t\t}\n"); } else { - Printf(output, "\t%s function %s(%s) {\n", acc, methodname, args); + Printf(output, "\t%sfunction %s(%s) {\n", acc, methodname, args); } Delete(acc); } else { From 741b90763b8945889bd6d3b49a5472149684ed9f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 11 Aug 2009 14:42:03 +0000 Subject: [PATCH 103/352] Fix to work for classes which aren't called "Foo"... git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11531 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 0ea23080f..c4c6bab25 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1604,7 +1604,8 @@ public: if (strcmp(methodname, "__construct") == 0) { Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke); } else { - Printf(output, "\t\treturn new %s(%s);\n", "Foo", invoke); + String *classname = Swig_class_name(current_class); + Printf(output, "\t\treturn new %s(%s);\n", classname, invoke); } } else { Node *parent = Swig_methodclass(n); From ac8f104d7b6f8cfbafee9657331211e92b03f0e2 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 11 Aug 2009 22:53:32 +0000 Subject: [PATCH 104/352] PHP: Add more comments in SWIG_ZTS_SetPointerZval() git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11536 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/phprun.swg | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index 3f762a3e5..f48748914 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -113,8 +113,14 @@ SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject value->ptr=ptr; value->newobject=newobject; if (newobject <= 1) { + /* Just register the pointer as a resource. */ ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata)); } else { + /* + * Wrap the resource in an object, the resource will be accessible + * via the "_cPtr" member. This is currently only used by + * directorin typemaps. + */ value->newobject = 0; zval *resource; MAKE_STD_ZVAL(resource); From 3076cbcdc0d7b07d3efcbf286e568f3663207161 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 12 Aug 2009 00:22:47 +0000 Subject: [PATCH 105/352] Fix seg fault in SWIG_Python_ConvertFunctionPtr() for invalid values git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11537 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pyrun.swg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 38632e1ab..21fddb610 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1163,10 +1163,10 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { /* here we get the method pointer for callbacks */ const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; - if (desc) { + if (desc) desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) return SWIG_ERROR; - } + if (!desc) + return SWIG_ERROR; if (ty) { swig_cast_info *tc = SWIG_TypeCheck(desc,ty); if (tc) { From 889b156afd1c6220f36827cdd49bae3b3618b901 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 12 Aug 2009 11:18:58 +0000 Subject: [PATCH 106/352] PHP: fix for the extend_template testcase The fix is not to handle a %template as a rename by reading the class' sym:name attribute instead of the ctor's name attribute. This has been broken in r11510. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11539 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index c4c6bab25..44fe032a5 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1027,11 +1027,11 @@ public: if (constructor) { class_has_ctor = true; // Skip the Foo:: prefix. - char *ptr = strrchr(GetChar(n, "name"), ':'); + char *ptr = strrchr(GetChar(Swig_methodclass(n), "sym:name"), ':'); if (ptr) { ptr++; } else { - ptr = GetChar(n, "name"); + ptr = GetChar(Swig_methodclass(n), "sym:name"); } if (strcmp(ptr, GetChar(n, "constructorHandler:sym:name")) == 0) { methodname = "__construct"; From 36c4707c0d3b06ced3056163966daf0f9b811588 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 12 Aug 2009 22:07:49 +0000 Subject: [PATCH 107/352] Correct docs wrt C preprocessor constants with a cast git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11541 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 1bdc6b4d0..fdbbab6f7 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -667,7 +667,6 @@ enum boolean {NO=0, YES=1}; enum months {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}; %constant double BLAH = 42.37; -#define F_CONST (double) 5 // A floating pointer constant with cast #define PI_4 PI/4 #define FLAGS 0x04 | 0x08 | 0x40 @@ -706,8 +705,15 @@ the declaration

      defines a constant because PI was already defined as a constant and the value is known. +However, for the same conservative reasons even a constant with a simple cast will be ignored, such as

      +
      +
      +#define F_CONST (double) 5            // A floating pointer constant with cast
      +
      +
      +

      The use of constant expressions is allowed, but SWIG does not evaluate them. Rather, it passes them through to the output file and lets the C From ce3d4db364e5ae42c5e260aabb370815fbd1d290 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 13 Aug 2009 03:31:38 +0000 Subject: [PATCH 108/352] Update the list of expected methods for smart_pointer_rename for PHP5 so this testcase now passes. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11543 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/smart_pointer_rename_runme.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/php/smart_pointer_rename_runme.php b/Examples/test-suite/php/smart_pointer_rename_runme.php index a1759cb95..c601cce16 100644 --- a/Examples/test-suite/php/smart_pointer_rename_runme.php +++ b/Examples/test-suite/php/smart_pointer_rename_runme.php @@ -5,8 +5,8 @@ require "tests.php"; require "smart_pointer_rename.php"; check::classes(array("Foo","Bar")); -check::classmethods("foo",array("foo","ftest1","ftest2")); -check::classmethods("bar",array("__deref__","bar","test","ftest1","ftest2")); +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); From 54018f66a2d530a785e7db361d5e604cb94459e4 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 13 Aug 2009 03:35:48 +0000 Subject: [PATCH 109/352] Correct the human-readable messages in 3 assertions. Remove meaningless comment. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11544 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/enum_scope_template_runme.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/php/enum_scope_template_runme.php b/Examples/test-suite/php/enum_scope_template_runme.php index 7cea23911..e152efca6 100644 --- a/Examples/test-suite/php/enum_scope_template_runme.php +++ b/Examples/test-suite/php/enum_scope_template_runme.php @@ -1,14 +1,12 @@ Date: Thu, 13 Aug 2009 03:58:09 +0000 Subject: [PATCH 110/352] Change class names in test code which clash with PHP reserved words (Interface, Class, and Function - these are case insensitive reserved words in PHP). Fix lists of expected methods in rename_scope_runme.php to match those which we expect with PHP5. With this and the change above, this testcase now passes. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11545 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/rename_scope_runme.php | 8 ++++---- Examples/test-suite/rename_scope.i | 10 +++++----- Examples/test-suite/template_default_qualify.i | 6 +++--- Examples/test-suite/template_enum_ns_inherit.i | 14 +++++++------- Examples/test-suite/template_enum_typedef.i | 6 +++--- Examples/test-suite/template_ns4.i | 16 ++++++++-------- Examples/test-suite/valuewrapper_base.i | 8 ++++---- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Examples/test-suite/php/rename_scope_runme.php b/Examples/test-suite/php/rename_scope_runme.php index 6da5c4a5c..6c66906c6 100644 --- a/Examples/test-suite/php/rename_scope_runme.php +++ b/Examples/test-suite/php/rename_scope_runme.php @@ -6,10 +6,10 @@ require "rename_scope.php"; check::classes(array("rename_scope","Interface_UP","Interface_BP","Natural_UP","Natural_BP","Bucket")); -check::classmethods("Interface_UP",array("__construct")); -check::classmethods("Interface_BP",array("__construct")); -check::classmethods("Natural_UP",array("__construct","rtest")); -check::classmethods("Natural_BP",array("__construct","rtest")); +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"); diff --git a/Examples/test-suite/rename_scope.i b/Examples/test-suite/rename_scope.i index 6bea35b0e..9a09949c4 100644 --- a/Examples/test-suite/rename_scope.i +++ b/Examples/test-suite/rename_scope.i @@ -7,7 +7,7 @@ enum Polarization { UnaryPolarization, BinaryPolarization }; template - struct Interface + struct Interface_ { }; } @@ -15,9 +15,9 @@ namespace oss { - // Interface - %template(Interface_UP) Interface; - %template(Interface_BP) Interface; + // Interface_ + %template(Interface_UP) Interface_; + %template(Interface_BP) Interface_; } %inline @@ -27,7 +27,7 @@ namespace oss namespace interfaces { template - struct Natural : Interface

      + struct Natural : Interface_

      { int test(void) { return 1; } }; diff --git a/Examples/test-suite/template_default_qualify.i b/Examples/test-suite/template_default_qualify.i index bcba1a44e..640011b2c 100644 --- a/Examples/test-suite/template_default_qualify.i +++ b/Examples/test-suite/template_default_qualify.i @@ -12,14 +12,14 @@ enum Polarization { UnaryPolarization, BinaryPolarization }; template - struct Interface + struct Interface_ { }; namespace modules { - template > + template > // *** problem here **** struct Module : base { @@ -35,7 +35,7 @@ namespace oss { - %template(Interface_UP) Interface; + %template(Interface_UP) Interface_; namespace modules { %template(Module_etraits) Module; diff --git a/Examples/test-suite/template_enum_ns_inherit.i b/Examples/test-suite/template_enum_ns_inherit.i index 8992eef6d..c617b5716 100644 --- a/Examples/test-suite/template_enum_ns_inherit.i +++ b/Examples/test-suite/template_enum_ns_inherit.i @@ -6,7 +6,7 @@ enum Polarization { UnaryPolarization, BinaryPolarization }; template - struct Interface + struct Interface_ { }; @@ -21,8 +21,8 @@ namespace oss { - %template(Interface_UP) Interface; - %template(Module_UPIUP) Module >; + %template(Interface_UP) Interface_; + %template(Module_UPIUP) Module >; } %inline %{ @@ -31,18 +31,18 @@ namespace oss namespace hello { struct HInterface1 : - Interface // this works (with fullns qualification) + Interface_ // this works (with fullns qualification) { }; struct HInterface2 : - Interface // this doesn't work + Interface_ // this doesn't work { }; - struct HModule1 : Module > { + struct HModule1 : Module > { }; } } -%} \ No newline at end of file +%} diff --git a/Examples/test-suite/template_enum_typedef.i b/Examples/test-suite/template_enum_typedef.i index 9752d0858..38444594e 100644 --- a/Examples/test-suite/template_enum_typedef.i +++ b/Examples/test-suite/template_enum_typedef.i @@ -9,7 +9,7 @@ enum Polarization { UnaryPolarization, BinaryPolarization }; template - struct Interface + struct Interface_ { }; @@ -25,7 +25,7 @@ typedef Traits traits; static const Polarization P = traits::pmode; - void get(Interface

      arg) { }; // Here P is only replace by traits::pmode + void get(Interface_

      arg) { }; // Here P is only replace by traits::pmode }; } @@ -34,6 +34,6 @@ namespace oss { - %template(Interface_UP) Interface; + %template(Interface_UP) Interface_; %template(Module_UP) Module; } diff --git a/Examples/test-suite/template_ns4.i b/Examples/test-suite/template_ns4.i index 34489c473..f5c134852 100644 --- a/Examples/test-suite/template_ns4.i +++ b/Examples/test-suite/template_ns4.i @@ -8,13 +8,13 @@ }; template - struct Function + struct Function_ { char *test() { return (char *) "test"; } }; template - struct ArithFunction : Function + struct ArithFunction : Function_ { }; @@ -40,7 +40,7 @@ }; template - class Class : public ArithFunction< typename traits::arg_type, + class Class_ : public ArithFunction< typename traits::arg_type, typename traits::res_type > { }; @@ -49,7 +49,7 @@ typename traits::base make_Class() { - return Class(); + return Class_(); } @@ -58,9 +58,9 @@ %{ namespace hello { - template struct Function ; + template struct Function_ ; template struct ArithFunction ; - template class Class ; + template class Class_ ; } %} @@ -69,9 +69,9 @@ // This complains only when using a namespace // %template() traits; - %template(Function_DD) Function ; + %template(Function_DD) Function_ ; %template(ArithFunction_DD) ArithFunction ; - %template(Class_DD) Class ; + %template(Class_DD) Class_ ; %template(make_Class_DD) make_Class ; } diff --git a/Examples/test-suite/valuewrapper_base.i b/Examples/test-suite/valuewrapper_base.i index 1698c3e03..63471bbc8 100644 --- a/Examples/test-suite/valuewrapper_base.i +++ b/Examples/test-suite/valuewrapper_base.i @@ -10,9 +10,9 @@ }; template - struct Interface : Base + struct Interface_ : Base { - Interface(const Base& b) { }; + Interface_(const Base& b) { }; }; template @@ -23,6 +23,6 @@ namespace oss { // Interface - %template(Interface_BP) Interface; - %template(make_Interface_BP) make >; + %template(Interface_BP) Interface_; + %template(make_Interface_BP) make >; } From dd96b09e6884b83f71f79a46959877d35bd0c6a5 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 13 Aug 2009 04:13:35 +0000 Subject: [PATCH 111/352] Fix the list of classes expected. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11546 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/li_carrays_runme.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/php/li_carrays_runme.php b/Examples/test-suite/php/li_carrays_runme.php index 8972b9fc2..b6d47e926 100644 --- a/Examples/test-suite/php/li_carrays_runme.php +++ b/Examples/test-suite/php/li_carrays_runme.php @@ -1,14 +1,15 @@ Date: Thu, 13 Aug 2009 14:58:27 +0000 Subject: [PATCH 112/352] Just disable SWIGWARN_PARSE_KEYWORD for li_math.i under PHP. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11547 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/li_math.i | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Examples/test-suite/li_math.i b/Examples/test-suite/li_math.i index db39cd3de..3aa3db303 100644 --- a/Examples/test-suite/li_math.i +++ b/Examples/test-suite/li_math.i @@ -1,2 +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 From 627d9faffd33e8b945f671478f1b4b1a67aa5640 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2009 21:41:23 +0000 Subject: [PATCH 113/352] Add PHP const ref typemaps for primitive types git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11549 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 +++ .../test-suite/php/primitive_ref_runme.php | 25 +++++++++++++++ Lib/php/php.swg | 31 +++++++++++++++++++ Lib/php/utils.i | 7 ++++- 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/php/primitive_ref_runme.php diff --git a/CHANGES.current b/CHANGES.current index e3f690daa..30cd03df7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-08-13: wsfulton + [PHP] Add const reference typemaps. const reference primitive types are + now passed by value rather than pointer like the other target languages. + 2009-08-08: wsfulton [Python] More user friendly AttributeError is raised when there are no constructors generated for the proxy class in the event that the diff --git a/Examples/test-suite/php/primitive_ref_runme.php b/Examples/test-suite/php/primitive_ref_runme.php new file mode 100644 index 000000000..6a5a3f43d --- /dev/null +++ b/Examples/test-suite/php/primitive_ref_runme.php @@ -0,0 +1,25 @@ + diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 42cb8db4a..09e293e6f 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -184,6 +184,21 @@ ZVAL_LONG(return_value,$1); } +%typemap(out) const int &, + const unsigned int &, + const short &, + const unsigned short &, + const long &, + const unsigned long &, + const signed char &, + const unsigned char &, + const bool &, + const size_t &, + const enum SWIGTYPE & +{ + ZVAL_LONG(return_value,*$1); +} + %typemap(directorin) int, unsigned int, short, @@ -203,6 +218,11 @@ ZVAL_BOOL(return_value,($1)?1:0); } +%typemap(out) const bool & +{ + ZVAL_BOOL(return_value,(*$1)?1:0); +} + %typemap(directorin) bool { ZVAL_BOOL($input,($1_name)?1:0); @@ -214,6 +234,12 @@ ZVAL_DOUBLE(return_value,$1); } +%typemap(out) const float &, + const double & +{ + ZVAL_DOUBLE(return_value,*$1); +} + %typemap(directorin) float, double { @@ -225,6 +251,11 @@ ZVAL_STRINGL(return_value,&$1, 1, 1); } +%typemap(out) const char & +{ + ZVAL_STRINGL(return_value,&*$1, 1, 1); +} + %typemap(out) char *, char [] { diff --git a/Lib/php/utils.i b/Lib/php/utils.i index f6fc2e5d2..69cec1004 100644 --- a/Lib/php/utils.i +++ b/Lib/php/utils.i @@ -33,10 +33,15 @@ %enddef %define %pass_by_val( TYPE, CONVERT_IN ) -%typemap(in) TYPE, const TYPE & +%typemap(in) TYPE %{ CONVERT_IN($1,$1_ltype,$input); %} +%typemap(in) const TYPE &($*1_ltype temp) +%{ + CONVERT_IN(temp,$*1_ltype,$input); + $1 = &temp; +%} %typemap(directorout) TYPE, const TYPE & %{ CONVERT_IN($result,$1_ltype,$input); From d2316a8189728032c32e659daf1f68ce9b0e2344 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2009 22:07:34 +0000 Subject: [PATCH 114/352] PHP std::vector wrappers overhaul modelling on Java std_vector.i. Work around empty rename warning problem. Add capacity and reserve(). Remove need for specialize_std_vector macro. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11550 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 + Lib/php/std_vector.i | 201 ++++++++++++++++++------------------------- 2 files changed, 90 insertions(+), 115 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 30cd03df7..4c7c2a93f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-08-13: wsfulton + [PHP] std::vector wrappers overhaul. They no longer require the + specialize_std_vector() macro. Added wrappers for capacity() and reserve(). + 2009-08-13: wsfulton [PHP] Add const reference typemaps. const reference primitive types are now passed by value rather than pointer like the other target languages. diff --git a/Lib/php/std_vector.i b/Lib/php/std_vector.i index b54181618..74991cc8c 100644 --- a/Lib/php/std_vector.i +++ b/Lib/php/std_vector.i @@ -3,132 +3,103 @@ * of SWIG, and the README file for authors - http://www.swig.org/release.html. * * std_vector.i - * - * SWIG typemaps for std::vector types * ----------------------------------------------------------------------------- */ %include -// ------------------------------------------------------------------------ -// std::vector -// -// The aim of all that follows would be to integrate std::vector with -// PHP as much as possible, namely, to allow the user to pass and -// be returned PHP lists. -// const declarations are used to guess the intent of the function being -// exported; therefore, the following rationale is applied: -// -// -- f(std::vector), f(const std::vector&), f(const std::vector*): -// the parameter being read-only, either a PHP sequence or a -// previously wrapped std::vector can be passed. -// -- f(std::vector&), f(std::vector*): -// the parameter must be modified; therefore, only a wrapped std::vector -// can be passed. -// -- std::vector f(): -// the vector is returned by copy; therefore, a PHP sequence of T:s -// is returned which is most easily used in other PHP functions -// -- std::vector& f(), std::vector* f(), const std::vector& f(), -// const std::vector* f(): -// the vector is returned by reference; therefore, a wrapped std::vector -// is returned -// ------------------------------------------------------------------------ - %{ #include -#include #include %} -// exported class - namespace std { - - template class vector { - // add generic typemaps here - public: - vector(unsigned int size = 0); - unsigned int size() const; - %rename(is_empty) empty; - bool empty() const; - void clear(); - %rename(push) push_back; - void push_back(const T& x); - %extend { - T pop() throw (std::out_of_range) { - if (self->size() == 0) - throw std::out_of_range("pop from empty vector"); - T x = self->back(); - self->pop_back(); - return x; - } - T& get(int i) throw (std::out_of_range) { - int size = int(self->size()); - if (i>=0 && isize()); - if (i>=0 && i class vector { + public: + typedef size_t size_type; + typedef T value_type; + typedef const value_type& const_reference; + vector(); + vector(size_type n); + size_type size() const; + size_type capacity() const; + void reserve(size_type n); + void clear(); + %rename(push) push_back; + void push_back(const value_type& x); + %extend { + bool is_empty() const { + return $self->empty(); + } + T pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + T x = self->back(); + self->pop_back(); + return x; + } + const_reference get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && isize()); + if (i>=0 && i class vector { - // add specialized typemaps here - public: - vector(unsigned int size = 0); - unsigned int size() const; - %rename(is_empty) empty; - bool empty() const; - void clear(); - %rename(push) push_back; - void push_back(T x); - %extend { - T pop() throw (std::out_of_range) { - if (self->size() == 0) - throw std::out_of_range("pop from empty vector"); - T x = self->back(); - self->pop_back(); - return x; - } - T get(int i) throw (std::out_of_range) { - int size = int(self->size()); - if (i>=0 && isize()); - if (i>=0 && i class vector { + public: + typedef size_t size_type; + typedef bool value_type; + typedef bool const_reference; + vector(); + vector(size_type n); + size_type size() const; + size_type capacity() const; + void reserve(size_type n); + void clear(); + %rename(push) push_back; + void push_back(const value_type& x); + %extend { + bool is_empty() const { + return $self->empty(); + } + bool pop() throw (std::out_of_range) { + if (self->size() == 0) + throw std::out_of_range("pop from empty vector"); + bool x = self->back(); + self->pop_back(); + return x; + } + const_reference get(int i) throw (std::out_of_range) { + int size = int(self->size()); + if (i>=0 && isize()); + if (i>=0 && i Date: Thu, 13 Aug 2009 22:39:20 +0000 Subject: [PATCH 115/352] add php typecheck typemaps for const reference for primitives git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11551 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/director_string_runme.php | 2 +- Lib/php/php.swg | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Examples/test-suite/php/director_string_runme.php b/Examples/test-suite/php/director_string_runme.php index b239e47fb..5ac583f78 100644 --- a/Examples/test-suite/php/director_string_runme.php +++ b/Examples/test-suite/php/director_string_runme.php @@ -4,7 +4,7 @@ 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)); +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 diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 09e293e6f..b41af8968 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -327,7 +327,7 @@ // an argument to be converted from a different PHP type, you must convert // it yourself before passing it (e.g. (string)4.7 or (int)"6"). %define %php_typecheck(_type,_prec,is) -%typemap(typecheck,precedence=_prec) _type +%typemap(typecheck,precedence=_prec) _type, const _type & " $1 = (Z_TYPE_PP($input) == is); " %enddef @@ -342,13 +342,12 @@ %php_typecheck(size_t,SWIG_TYPECHECK_INT16,IS_LONG) %php_typecheck(enum SWIGTYPE,SWIG_TYPECHECK_INT8,IS_LONG) %php_typecheck(bool,SWIG_TYPECHECK_BOOL,IS_BOOL) - -%php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING) -%php_typecheck(char *,SWIG_TYPECHECK_STRING,IS_STRING) -%php_typecheck(char [],SWIG_TYPECHECK_STRING,IS_STRING) - %php_typecheck(float,SWIG_TYPECHECK_FLOAT,IS_DOUBLE) %php_typecheck(double,SWIG_TYPECHECK_BOOL,IS_DOUBLE) +%php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING) + +%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, const char *&, char [] + " $1 = (Z_TYPE_PP($input) == IS_STRING); " %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE { From cc43f20f6d260504582621e1a241461639bd2041 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2009 23:31:19 +0000 Subject: [PATCH 116/352] PHP fix const char\*\& typemaps and add in char_strings runtime test based on Java version git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11552 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/char_strings.i | 12 +++++ .../test-suite/php/char_strings_runme.php | 44 +++++++++++++++++++ Lib/php/php.swg | 19 ++++++-- Lib/php/utils.i | 2 +- 4 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 Examples/test-suite/php/char_strings_runme.php diff --git a/Examples/test-suite/char_strings.i b/Examples/test-suite/char_strings.i index 12e4b5aa2..2561108c6 100644 --- a/Examples/test-suite/char_strings.i +++ b/Examples/test-suite/char_strings.i @@ -149,6 +149,18 @@ const char global_const_char_array2[sizeof(CPLUSPLUS_MSG)+1] = CPLUSPLUS_MSG; %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; diff --git a/Examples/test-suite/php/char_strings_runme.php b/Examples/test-suite/php/char_strings_runme.php new file mode 100644 index 000000000..ff75afc58 --- /dev/null +++ b/Examples/test-suite/php/char_strings_runme.php @@ -0,0 +1,44 @@ + + diff --git a/Lib/php/php.swg b/Lib/php/php.swg index b41af8968..1a953650f 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -64,6 +64,8 @@ %pass_by_val(double, CONVERT_FLOAT_IN); %pass_by_val(char *, CONVERT_STRING_IN); +%typemap(in) char *& = const char *&; +%typemap(directorout) char *& = const char *&; // char array can be in/out, though the passed string may not be big enough... // so we have to size it @@ -241,7 +243,7 @@ } %typemap(directorin) float, - double + double { ZVAL_DOUBLE($input,$1_name); } @@ -266,6 +268,15 @@ } } +%typemap(out) char *& +{ + if(!*$1) { + ZVAL_NULL(return_value); + } else { + ZVAL_STRING(return_value, (char *)*$1, 1); + } +} + %typemap(out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE & @@ -274,8 +285,8 @@ %} %typemap(directorin) SWIGTYPE *, - SWIGTYPE [], - SWIGTYPE & + SWIGTYPE [], + SWIGTYPE & %{ SWIG_SetPointerZval($input, (void *)&$1_name, $1_descriptor, $owner); %} @@ -346,7 +357,7 @@ %php_typecheck(double,SWIG_TYPECHECK_BOOL,IS_DOUBLE) %php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING) -%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, const char *&, char [] +%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&, char [] " $1 = (Z_TYPE_PP($input) == IS_STRING); " %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE diff --git a/Lib/php/utils.i b/Lib/php/utils.i index 69cec1004..cadba3c2f 100644 --- a/Lib/php/utils.i +++ b/Lib/php/utils.i @@ -37,7 +37,7 @@ %{ CONVERT_IN($1,$1_ltype,$input); %} -%typemap(in) const TYPE &($*1_ltype temp) +%typemap(in) const TYPE & ($*1_ltype temp) %{ CONVERT_IN(temp,$*1_ltype,$input); $1 = &temp; From d1a6d960eb28c42715cb075bd424a27d5ed56644 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 13 Aug 2009 23:37:05 +0000 Subject: [PATCH 117/352] Add non-const char *& runtime tests git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11553 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp/char_strings_runme.cs | 15 +++++++++++++-- Examples/test-suite/java/char_strings_runme.java | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/csharp/char_strings_runme.cs b/Examples/test-suite/csharp/char_strings_runme.cs index a8907fb16..59bcc64df 100644 --- a/Examples/test-suite/csharp/char_strings_runme.cs +++ b/Examples/test-suite/csharp/char_strings_runme.cs @@ -120,15 +120,26 @@ public class char_strings_runme { // char *& tests for (i=0; i Date: Fri, 14 Aug 2009 00:15:23 +0000 Subject: [PATCH 118/352] Zap extra blank line after ?> which appears in testsuite output git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11554 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/char_strings_runme.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Examples/test-suite/php/char_strings_runme.php b/Examples/test-suite/php/char_strings_runme.php index ff75afc58..e06ee9d2b 100644 --- a/Examples/test-suite/php/char_strings_runme.php +++ b/Examples/test-suite/php/char_strings_runme.php @@ -41,4 +41,3 @@ check::equal(SetConstCharPointerRef($OTHERLAND_MSG_10, 10), true, "failed SetCon check::done(); ?> - From 3675a7baf7dca8e0826f84bda7760f497c18ce97 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 14 Aug 2009 01:00:36 +0000 Subject: [PATCH 119/352] Add min and max as built-in functions. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11555 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/phpkw.swg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/php/phpkw.swg b/Lib/php/phpkw.swg index e38f5e6a4..a5f410bc5 100644 --- a/Lib/php/phpkw.swg +++ b/Lib/php/phpkw.swg @@ -13,7 +13,6 @@ #define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP") "::" `x` #define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x` - /* From @@ -475,6 +474,8 @@ PHPFN(sqrt); PHPFN(ceil); PHPFN(floor); PHPFN(fmod); +PHPFN(min); +PHPFN(max); #undef PHPKW #undef PHPBN1 From 45359dc12c1caed9374820d576e9dc8746557e74 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 14 Aug 2009 01:14:49 +0000 Subject: [PATCH 120/352] Add SWIGTYPE *& typemaps for PHP git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11556 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../php/pointer_reference_runme.php | 14 +++++++++++++ Lib/php/php.swg | 20 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/php/pointer_reference_runme.php diff --git a/Examples/test-suite/php/pointer_reference_runme.php b/Examples/test-suite/php/pointer_reference_runme.php new file mode 100644 index 000000000..8fc67a134 --- /dev/null +++ b/Examples/test-suite/php/pointer_reference_runme.php @@ -0,0 +1,14 @@ + diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 1a953650f..136326cb7 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -114,6 +114,14 @@ } } +%typemap(in) SWIGTYPE *& ($*ltype temp) +{ + if(SWIG_ConvertPtr(*$input, (void **) &temp, $*1_descriptor, 0) < 0) { + SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $*1_descriptor"); + } + $1 = &temp; +} + %typemap(in) SWIGTYPE *DISOWN { if(SWIG_ConvertPtr(*$input, (void **) &$1, $1_descriptor, SWIG_POINTER_DISOWN ) < 0) { @@ -284,6 +292,11 @@ SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); %} +%typemap(out) SWIGTYPE *& +%{ + SWIG_SetPointerZval(return_value, (void *)*$1, $*1_descriptor, $owner); +%} + %typemap(directorin) SWIGTYPE *, SWIGTYPE [], SWIGTYPE & @@ -325,6 +338,10 @@ } #endif +/* Array reference typemaps */ +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + + %typemap(out) void ""; %typemap(out) char [ANY] @@ -368,7 +385,8 @@ %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [], - SWIGTYPE & + SWIGTYPE &, + SWIGTYPE *& { void *tmp; _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0); From 84215444eb3d4ae299d81f028cfa7eff90f8a1ec Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 14 Aug 2009 01:33:23 +0000 Subject: [PATCH 121/352] Rename max() to maximum() as max() is a built-in function in PHP. Testcases overload_template and overload_template_fast now pass for PHP. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11557 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/csharp/overload_template_runme.cs | 4 ++-- .../test-suite/java/overload_template_runme.java | 4 ++-- .../test-suite/lua/overload_template_runme.lua | 4 ++-- .../test-suite/octave/overload_template_runme.m | 4 ++-- Examples/test-suite/overload_template.i | 14 ++++---------- .../test-suite/python/overload_template_runme.py | 4 ++-- .../test-suite/ruby/overload_template_runme.rb | 4 ++-- 7 files changed, 16 insertions(+), 22 deletions(-) diff --git a/Examples/test-suite/csharp/overload_template_runme.cs b/Examples/test-suite/csharp/overload_template_runme.cs index e4910161b..e25420169 100644 --- a/Examples/test-suite/csharp/overload_template_runme.cs +++ b/Examples/test-suite/csharp/overload_template_runme.cs @@ -7,8 +7,8 @@ public class runme { int f = overload_template.foo(); - f += overload_template.max(3,4); - double b = overload_template.max(3.4,5.2); + f += overload_template.maximum(3,4); + double b = overload_template.maximum(3.4,5.2); b++; // warning suppression // mix 1 diff --git a/Examples/test-suite/java/overload_template_runme.java b/Examples/test-suite/java/overload_template_runme.java index e76bf63ee..bda1853be 100644 --- a/Examples/test-suite/java/overload_template_runme.java +++ b/Examples/test-suite/java/overload_template_runme.java @@ -16,8 +16,8 @@ public class overload_template_runme { public static void main(String argv[]) { int f = overload_template.foo(); - int a = overload_template.max(3,4); - double b = overload_template.max(3.4,5.2); + int a = overload_template.maximum(3,4); + double b = overload_template.maximum(3.4,5.2); // mix 1 if (overload_template.mix1("hi") != 101) diff --git a/Examples/test-suite/lua/overload_template_runme.lua b/Examples/test-suite/lua/overload_template_runme.lua index c62a42c02..19cc7e9dd 100644 --- a/Examples/test-suite/lua/overload_template_runme.lua +++ b/Examples/test-suite/lua/overload_template_runme.lua @@ -2,12 +2,12 @@ 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 max(int,int) and max(double,double) are the same +-- 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 = max(3,4) +a = maximum(3,4) -- mix 1 assert(mix1("hi") == 101) diff --git a/Examples/test-suite/octave/overload_template_runme.m b/Examples/test-suite/octave/overload_template_runme.m index b38dc73e1..d7b1cbb65 100644 --- a/Examples/test-suite/octave/overload_template_runme.m +++ b/Examples/test-suite/octave/overload_template_runme.m @@ -1,8 +1,8 @@ overload_template f = foo(); -a = max(3,4); -b = max(3.4,5.2); +a = maximum(3,4); +b = maximum(3.4,5.2); # mix 1 if (mix1("hi") != 101) diff --git a/Examples/test-suite/overload_template.i b/Examples/test-suite/overload_template.i index a889dbfda..dee6ab91e 100644 --- a/Examples/test-suite/overload_template.i +++ b/Examples/test-suite/overload_template.i @@ -3,7 +3,7 @@ #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) max; +%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; @@ -11,12 +11,6 @@ %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) barT; #endif -%{ -#ifdef max -#undef max -#endif -%} - %inline %{ int foo() { @@ -29,15 +23,15 @@ template } template - T max(T a, T b) { return (a > b) ? a : b; } + T maximum(T a, T b) { return (a > b) ? a : b; } %} %template(foo) foo; %template(foo) foo; -%template(max) max; -%template(max) max; +%template(maximum) maximum; +%template(maximum) maximum; // Mix template overloading with plain function overload // Mix 1 diff --git a/Examples/test-suite/python/overload_template_runme.py b/Examples/test-suite/python/overload_template_runme.py index 3fd77f339..c1337ba6a 100644 --- a/Examples/test-suite/python/overload_template_runme.py +++ b/Examples/test-suite/python/overload_template_runme.py @@ -1,8 +1,8 @@ from overload_template import * f = foo() -a = max(3,4) -b = max(3.4,5.2) +a = maximum(3,4) +b = maximum(3.4,5.2) # mix 1 if (mix1("hi") != 101): diff --git a/Examples/test-suite/ruby/overload_template_runme.rb b/Examples/test-suite/ruby/overload_template_runme.rb index bcbddf512..b099fd3ea 100755 --- a/Examples/test-suite/ruby/overload_template_runme.rb +++ b/Examples/test-suite/ruby/overload_template_runme.rb @@ -13,5 +13,5 @@ require 'overload_template' f = Overload_template.foo() -a = Overload_template.max(3,4) -b = Overload_template.max(3.4,5.2) +a = Overload_template.maximum(3,4) +b = Overload_template.maximum(3.4,5.2) From 6f80e2f7a69224e7608c2b845537f575f580c572 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 14 Aug 2009 04:22:03 +0000 Subject: [PATCH 122/352] PHP: Add directorout typemap for primitive type const refs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11559 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/utils.i | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/php/utils.i b/Lib/php/utils.i index cadba3c2f..166941585 100644 --- a/Lib/php/utils.i +++ b/Lib/php/utils.i @@ -42,10 +42,15 @@ CONVERT_IN(temp,$*1_ltype,$input); $1 = &temp; %} -%typemap(directorout) TYPE, const TYPE & +%typemap(directorout) TYPE %{ CONVERT_IN($result,$1_ltype,$input); %} +%typemap(directorout) const TYPE & ($*1_ltype temp) +%{ + CONVERT_IN(temp,$*1_ltype,$input); + $result = &temp; +%} %enddef %fragment("t_output_helper","header") %{ From e0683051251aefa3c9aec07cb6c6888e54418b97 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 14 Aug 2009 07:53:38 +0000 Subject: [PATCH 123/352] If there's no prefix, special case to avoid prepending an empty string. Don't calculate $class in the stdClass case when we don't need it. Eliminate an unnecessary else. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11563 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 44fe032a5..ae4463238 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1651,15 +1651,19 @@ public: * TODO: do this in a more elegant way */ Printf(output, "\t\tif (is_resource($r)) {\n"); - Printf(output, "\t\t\t$class='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); if (Getattr(classLookup(Getattr(n, "type")), "module")) { + if (Len(prefix) == 0) { + Printf(output, "\t\t\t$class=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n"); + } else { + Printf(output, "\t\t\t$class='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); + } Printf(output, "\t\t\treturn new $class($r);\n"); } else { Printf(output, "\t\t\t$c = new stdClass();\n"); Printf(output, "\t\t\t$c->_cPtr = $r;\n"); Printf(output, "\t\t\treturn $c;\n"); } - Printf(output, "\t\t}\n\t\telse return $r;\n"); + Printf(output, "\t\t}\n\t\treturn $r;\n"); } else { Printf(output, "\t\t$this->%s = $r;\n", SWIG_PTR); Printf(output, "\t\treturn $this;\n"); From e125ce326db5f53085d9f42fff108f4ebc5b3151 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 14 Aug 2009 08:04:21 +0000 Subject: [PATCH 124/352] If $c would be used as a parameter name, rename it to $c_ to avoid issues if call-time pass-by-reference is enabled and used. Use $c instead of $class to keep down the number of "reserved" parameter names. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11564 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index ae4463238..0f12bcfc3 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1392,9 +1392,11 @@ public: /* We use $r to store the return value, so disallow that as a parameter * name in case the user uses the "call-time pass-by-reference" feature * (it's deprecated and off by default in PHP5, but we want to be - * maximally portable). + * maximally portable). Similarly we use $c for the classname or new + * stdClass object. */ Setattr(seen, "r", seen); + Setattr(seen, "c", seen); for (int argno = 0; argno < max_num_of_arguments; ++argno) { String *&pname = arg_names[argno]; @@ -1653,11 +1655,11 @@ public: Printf(output, "\t\tif (is_resource($r)) {\n"); if (Getattr(classLookup(Getattr(n, "type")), "module")) { if (Len(prefix) == 0) { - Printf(output, "\t\t\t$class=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n"); + Printf(output, "\t\t\t$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n"); } else { - Printf(output, "\t\t\t$class='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); + Printf(output, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); } - Printf(output, "\t\t\treturn new $class($r);\n"); + Printf(output, "\t\t\treturn new $c($r);\n"); } else { Printf(output, "\t\t\t$c = new stdClass();\n"); Printf(output, "\t\t\t$c->_cPtr = $r;\n"); From 1b42d9dde1cd722c16f8ac3917f21fdb2670dad0 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 14 Aug 2009 09:01:31 +0000 Subject: [PATCH 125/352] [PHP] Update the PHP "class" example to work with PHP5 and use modern wrapping features. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11565 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/php/class/Makefile | 2 +- Examples/php/class/runme.php | 38 ++++++++++++++++-------------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 4c7c2a93f..fb98f0d28 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-08-14: olly + [PHP] Update the PHP "class" example to work with PHP5 and use + modern wrapping features. + 2009-08-13: wsfulton [PHP] std::vector wrappers overhaul. They no longer require the specialize_std_vector() macro. Added wrappers for capacity() and reserve(). diff --git a/Examples/php/class/Makefile b/Examples/php/class/Makefile index 252a72660..1bc0beaab 100644 --- a/Examples/php/class/Makefile +++ b/Examples/php/class/Makefile @@ -4,7 +4,7 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -SWIGOPT = -noproxy +SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ diff --git a/Examples/php/class/runme.php b/Examples/php/class/runme.php index a9ca657dc..12b686052 100644 --- a/Examples/php/class/runme.php +++ b/Examples/php/class/runme.php @@ -1,22 +1,20 @@ x = 20; +$c->y = 30; +$s->x = -10; +$s->y = 5; print "\nHere is their current position:\n"; -print " Circle = (" . Shape_x_get($c) . "," . Shape_y_get($c) . ")\n"; -print " Square = (" . Shape_x_get($s) . "," . Shape_y_get($s) . ")\n"; +print " Circle = ({$c->x},{$c->y})\n"; +print " Square = ({$s->x},{$s->y})\n"; # ----- Call some methods ----- @@ -39,18 +37,16 @@ print " Square = (" . Shape_x_get($s) . "," . Shape_y_get($s) . ")\n"; # invoke the appropriate virtual method on each object. print "\nHere are some properties of the shapes:\n"; foreach (array($c,$s) as $o) { - print " $o\n"; - print " area = " . Shape_area($o) . "\n"; - print " perimeter = " . Shape_perimeter($o) . "\n"; - } + 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 -#delete_Shape($c); -#delete_Shape($s); $c = NULL; $s = NULL; @@ -58,7 +54,7 @@ $s = NULL; # the square. $o = NULL; -print nshapes() . " shapes remain\n"; +print Shape::get_nshapes() . " shapes remain\n"; print "Goodbye\n"; ?> From f4e3444ae3d0c5ef233810484b4244f75928146e Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 14 Aug 2009 09:44:15 +0000 Subject: [PATCH 126/352] Use module name instead of hardcoded "example" in __get(). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11567 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 0f12bcfc3..91d75a046 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2046,7 +2046,7 @@ public: Printf(s_phpclasses, "\t}\n"); } else { Printf(s_phpclasses, "\n\tfunction __get($var) {\n"); - Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_example_get_newobject($this->%s);\n", SWIG_PTR); + Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR); Printf(s_phpclasses, "\t\telse return $this->%s[$var];\n", SWIG_DATA); Printf(s_phpclasses, "\t}\n"); } From 57017bd6bc1f5465b0fdc94185a06ece26a549a9 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 14 Aug 2009 16:22:15 +0000 Subject: [PATCH 127/352] [PHP] PHP5 now wraps static member variables as documented. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11570 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 ++ Source/Modules/php.cxx | 104 ++++++++++++++--------------------------- 2 files changed, 39 insertions(+), 68 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index fb98f0d28..da76ebb40 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.40 (in progress) ============================ +2009-08-14: olly + [PHP] PHP5 now wraps static member variables as documented. + 2009-08-14: olly [PHP] Update the PHP "class" example to work with PHP5 and use modern wrapping features. diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 91d75a046..b41ab7b1f 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -9,10 +9,6 @@ */ /* FIXME: PHP5 OO wrapping TODO list: - * - * Short term: - * - * Sort out wrapping of static member variables in OO PHP5. * * Medium term: * @@ -766,8 +762,8 @@ public: String *outarg = NewStringEmpty(); String *cleanup = NewStringEmpty(); - // Not issued for overloaded functions or static member variables. - if (!overloaded && wrapperType != staticmembervar) { + // Not issued for overloaded functions. + if (!overloaded) { create_command(iname, wname); } Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); @@ -1721,6 +1717,40 @@ public: } free(arg_names); arg_names = NULL; + } else if (wrapperType == staticmembervar) { + // FIXME: this case ought to be folded into the one above so that it + // handles wrapping static members which are themselves objects. + + // Static member variable, wrapped as a function due to PHP limitations. + const char *methodname = 0; + String *output = s_oowrappers; + methodname = Char(Getattr(n, "staticmembervariableHandler:sym:name")); + + // We're called twice for a writable static member variable - first with + // "foo_set" and then with "foo_get" - so generate half the wrapper + // function each time. + // + // For a const static member, we only get called once. + static bool started = false; + const char *p = Char(iname); + if (strlen(p) > 4) { + p += strlen(p) - 4; + if (!started) { + started = true; + Printf(output, "\n\tstatic function %s() {\n", methodname); + if (strcmp(p, "_set") == 0) { + Printf(output, "\t\tif (func_num_args()) {\n"); + Printf(output, "\t\t\t%s(func_get_arg(0));\n", iname); + Printf(output, "\t\t\treturn;\n"); + Printf(output, "\t\t}\n"); + } + } + if (strcmp(p, "_get") == 0) { + started = false; + Printf(output, "\t\treturn %s();\n", iname); + Printf(output, "\t}\n"); + } + } } DelWrapper(f); @@ -2110,68 +2140,6 @@ public: Language::staticmembervariableHandler(n); wrapperType = standard; - SwigType *type = Getattr(n, "type"); - String *name = Getattr(n, "name"); - String *iname = Getattr(n, "sym:name"); - - /* A temporary(!) hack for static member variables. - * PHP currently supports class functions, but not class variables. - * Until it does, we convert a class variable to a class function - * that returns the current value of the variable. E.g. - * - * class Example { - * public: - * static int ncount; - * }; - * - * would be available in PHP as Example::ncount() - */ - - // If the variable is const, then it's wrapped as a constant with set/get - // functions. - if (SwigType_isconst(type)) - return SWIG_OK; - - // This duplicates the logic from Language::variableWrapper() to test if - // the set wrapper is made. - int assignable = is_assignable(n); - if (assignable) { - String *tm = Swig_typemap_lookup("globalin", n, name, 0); - if (!tm && SwigType_isarray(type)) { - assignable = 0; - } - } - - String *class_iname = Swig_name_member(Getattr(current_class, "sym:name"), iname); - String *lclass_iname = NewStringf("%(lower)s", class_iname); - create_command(lclass_iname, Swig_name_wrapper(class_iname)); - Delete(lclass_iname); - - Wrapper *f = NewWrapper(); - - Printv(f->def, "ZEND_NAMED_FUNCTION(", Swig_name_wrapper(class_iname), ") {\n", NIL); - String *mget = Swig_name_wrapper(Swig_name_get(class_iname)); - String *mset = Swig_name_wrapper(Swig_name_set(class_iname)); - - if (assignable) { - Printf(f->code, "if (ZEND_NUM_ARGS() > 0 ) {\n"); - Printf(f->code, " %s( INTERNAL_FUNCTION_PARAM_PASSTHRU );\n", mset); - Printf(f->code, " // need some error checking here?\n"); - Printf(f->code, " // Set the argument count to 0 for the get call\n"); - Printf(f->code, " ht = 0;\n"); - Printf(f->code, "}\n"); - } - - Printf(f->code, "%s( INTERNAL_FUNCTION_PARAM_PASSTHRU );\n", mget); - Printf(f->code, "}\n"); - - Wrapper_print(f, s_wrappers); - - Delete(class_iname); - Delete(mget); - Delete(mset); - DelWrapper(f); - return SWIG_OK; } From ba29cea2b519672a8304f4195c87b263ff242d19 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 14 Aug 2009 17:01:20 +0000 Subject: [PATCH 128/352] Minor cleanups. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11571 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index b41ab7b1f..bac95bd93 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -979,6 +979,8 @@ public: Replaceall(f->code, "$symname", iname); Wrapper_print(f, s_wrappers); + DelWrapper(f); + f = NULL; if (overloaded && !Getattr(n, "sym:nextSibling")) { dispatchFunction(n); @@ -988,7 +990,6 @@ public: wname = NULL; if (!shadow) { - DelWrapper(f); return SWIG_OK; } @@ -1004,6 +1005,7 @@ public: Setattr(shadow_set_vars, varname, iname); } } + return SWIG_OK; } // Only look at non-overloaded methods and the last entry in each overload // chain (we check the last so that wrap:parms and wrap:name have been set @@ -1013,6 +1015,7 @@ public: if (!s_oowrappers) s_oowrappers = NewStringEmpty(); + if (newobject || wrapperType == memberfn || wrapperType == staticmemberfn || wrapperType == standard) { bool handle_as_overload = false; String **arg_names; @@ -1753,8 +1756,6 @@ public: } } - DelWrapper(f); - return SWIG_OK; } From 10edc69383693bb3d483e996d8d3a92493423413 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 14 Aug 2009 21:05:06 +0000 Subject: [PATCH 129/352] SWIG_ConvertPtrAndOwn() into the runtime for Perl git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11572 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Lib/perl5/perlrun.swg | 20 +++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index da76ebb40..c4190883e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.40 (in progress) ============================ +2009-08-14: wsfulton + [Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer + memory ownership control. shared_ptr support still to be added. Patch from + David Fletcher. + 2009-08-14: olly [PHP] PHP5 now wraps static member variables as documented. diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index 6fb2968f0..be788f540 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -18,6 +18,7 @@ /* for raw pointers */ #define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Perl_ConvertPtr(SWIG_PERL_OBJECT_CALL obj, pp, type, flags) +#define SWIG_ConvertPtrAndOwn(obj, pp, type, flags,own) SWIG_Perl_ConvertPtrAndOwn(SWIG_PERL_OBJECT_CALL obj, pp, type, flags, own) #define SWIG_NewPointerObj(p, type, flags) SWIG_Perl_NewPointerObj(SWIG_PERL_OBJECT_CALL p, type, flags) /* for raw packed data */ @@ -234,10 +235,14 @@ SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { /* Function for getting a pointer value */ SWIGRUNTIME int -SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { +SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags, int *own) { swig_cast_info *tc; void *voidptr = (void *)0; SV *tsv = 0; + + if (own) + *own = 0; + /* If magical, apply more magic */ if (SvGMAGICAL(sv)) mg_get(sv); @@ -287,7 +292,11 @@ SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info * { int newmemory = 0; *ptr = SWIG_TypeCast(tc,voidptr,&newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ + if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); + if (own) + *own = *own | SWIG_CAST_NEW_MEMORY; + } } } else { *ptr = voidptr; @@ -317,9 +326,14 @@ SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info * return SWIG_OK; } +SWIGRUNTIME int +SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) { + return SWIG_Perl_ConvertPtrAndOwn(sv, ptr, _t, flags, 0); +} + SWIGRUNTIME void SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, int flags) { - if (ptr && (flags & SWIG_SHADOW)) { + if (ptr && (flags & (SWIG_SHADOW | SWIG_POINTER_OWN))) { SV *self; SV *obj=newSV(0); HV *hash=newHV(); From a717dbd10b8d3ee23601aee790c6779abcaa6e22 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 14 Aug 2009 22:11:27 +0000 Subject: [PATCH 130/352] Add some notes about \%extend and constructors git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11573 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index fdbbab6f7..31964bbe1 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -2388,6 +2388,10 @@ You can make a Vector look a lot like a class by writing a SWIG interfa

      Note the usage of the $self special variable. Its usage is identical to a C++ 'this' pointer and should be used whenever access to the struct instance is required. +Also note that C++ constructor and destructor syntax has been used to simulate a constructor and destructor, even for C code. +There is one subtle difference to a normal C++ constructor implementation though and that is although the constructor declaration +is as per a normal C++ constructor, the newly constructed object must be returned as if the constructor declaration +had a return value, a Vector * in this case.

      From 265adcae79d495bf3acaf630a4a487c2e025af6b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 14 Aug 2009 22:13:21 +0000 Subject: [PATCH 131/352] Fill in missing bit about the begin section git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11574 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 31964bbe1..8705fa182 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -2716,6 +2716,10 @@ initialization code (in that order).

        +
      • Begin section.
        +A placeholder to put code at the beginning of the C/C++ wrapper file. +
      • +
      • Runtime code.
        This code is internal to SWIG and is used to include type-checking and other support functions that are used by the rest of the module. From 06c06f8742720e83f2f615ed84ad3695b93f5df1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 14 Aug 2009 22:47:11 +0000 Subject: [PATCH 132/352] remove redundant if not __cplusplus for directorin typemap - directors are always c++ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11575 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/php.swg | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 136326cb7..a604b035b 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -326,17 +326,9 @@ #endif %typemap(directorin) SWIGTYPE -#ifdef __cplusplus { SWIG_SetPointerZval($input, SWIG_as_voidptr(&$1_name), $&1_descriptor, 2); } -#else -{ - $&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type)); - memcpy(resultobj, &$1, sizeof($1_type)); - SWIG_SetPointerZval($input, (void *)resultobj, $&1_descriptor, 2); -} -#endif /* Array reference typemaps */ %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } From 55170f0f88e5df7f28710d50982da5dd40d8fc04 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Aug 2009 00:17:21 +0000 Subject: [PATCH 133/352] Add Ruby missing methods for vector specialization git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11576 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 +++ .../test-suite/ruby/li_std_vector_runme.rb | 7 ++++++ Lib/ruby/rubycontainer.swg | 25 +------------------ 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c4190883e..c2ce13d66 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-08-15: wsfulton + [Ruby] Add numerous missing wrapped methods for std::vector specialization + as reported by Youssef Jones. + 2009-08-14: wsfulton [Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer memory ownership control. shared_ptr support still to be added. Patch from diff --git a/Examples/test-suite/ruby/li_std_vector_runme.rb b/Examples/test-suite/ruby/li_std_vector_runme.rb index 484f1888e..8bcad2d19 100755 --- a/Examples/test-suite/ruby/li_std_vector_runme.rb +++ b/Examples/test-suite/ruby/li_std_vector_runme.rb @@ -98,6 +98,13 @@ 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 diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index 919695ec2..df3f520d8 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -875,31 +875,8 @@ namespace swig } %enddef -// ..I don't think %swig_sequence_methods_val are really used at all anymore... %define %swig_sequence_methods_val(Sequence...) - %swig_sequence_methods_common(%arg(Sequence)) - %extend { - - VALUE __getitem__(difference_type i) { - VALUE r = Qnil; - try { - r = swig::from< Sequence::value_type >( *(swig::cgetpos(self, i)) ); - } - catch( std::out_of_range ) - { - } - return r; - } - - VALUE __setitem__(difference_type i, value_type x) { - std::size_t len = $self->size(); - if ( i < 0 ) i = len - i; - else if ( static_cast(i) >= len ) - $self->resize( i+1, x ); - else *(swig::getpos(self,i)) = x; - return swig::from< Sequence::value_type >( x ); - } - } + %swig_sequence_methods(%arg(Sequence)) %enddef From b81cb3bff9fef536650e415b8d34612a57678c92 Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Sat, 15 Aug 2009 01:19:28 +0000 Subject: [PATCH 134/352] try not to require -api option in octave git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11577 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/octave/octrun.swg | 22 ++++++++++++++++++++++ Source/Modules/octave.cxx | 4 ++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 759cf3c37..a2bf52070 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -1,4 +1,26 @@ +#if OCTAVE_API_VERSION_OPTION>0 +#define USE_OCTAVE_API_VERSION OCTAVE_API_VERSION_OPTION +#else + +#include +#ifdef OCTAVE_API_VERSION_N +#define USE_OCTAVE_API_VERSION OCTAVE_API_VERSION_N + +#else // Interim hack to distinguish between Octave 3.2 and earlier versions. + +#define ComplexLU __ignore +#include +#undef ComplexLU +#ifdef octave_Complex_LU_h +#define USE_OCTAVE_API_VERSION 36 +#else +#define USE_OCTAVE_API_VERSION 37 +#endif + +#endif + +#endif SWIGRUNTIME bool SWIG_check_num_args(const char *func_name, int num_args, int max_args, int min_args, int varargs) { if (num_args > max_args && !varargs) diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 9f924332d..aeb72f77a 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -56,7 +56,7 @@ public: director_multiple_inheritance = 1; director_language = 1; docs = NewHash(); - api_version = 37; + api_version = 0; } virtual void main(int argc, char *argv[]) { @@ -138,7 +138,7 @@ public: Printf(f_runtime, "#define SWIGOCTAVE\n"); Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module); Printf(f_runtime, "#define SWIG_name %s\n", module); - Printf(f_runtime, "#define USE_OCTAVE_API_VERSION %i\n", api_version); + Printf(f_runtime, "#define OCTAVE_API_VERSION_OPTION %i\n", api_version); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); From f3d0ebbf1809dfd1ca6170e23b72701039700be5 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 15 Aug 2009 05:33:05 +0000 Subject: [PATCH 135/352] Refactor the recent support for wrapping static member variables for PHP5 so it works for static members which are themselves classes. With this and the previous patch, li_std_string now passes and all other tests pass/fail as before. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11578 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 67 +++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 37 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index bac95bd93..dc7f863e3 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -118,8 +118,7 @@ static enum { membervar, staticmembervar, constructor, - directorconstructor, - destructor + directorconstructor } wrapperType = standard; extern "C" { @@ -1007,6 +1006,7 @@ public: } return SWIG_OK; } + // Only look at non-overloaded methods and the last entry in each overload // chain (we check the last so that wrap:parms and wrap:name have been set // for them all). @@ -1016,7 +1016,7 @@ public: if (!s_oowrappers) s_oowrappers = NewStringEmpty(); - if (newobject || wrapperType == memberfn || wrapperType == staticmemberfn || wrapperType == standard) { + if (newobject || wrapperType == memberfn || wrapperType == staticmemberfn || wrapperType == standard || wrapperType == staticmembervar) { bool handle_as_overload = false; String **arg_names; String **arg_values; @@ -1043,6 +1043,9 @@ public: methodname = Char(Getattr(n, "memberfunctionHandler:sym:name")); } else if (wrapperType == staticmemberfn) { methodname = Char(Getattr(n, "staticmemberfunctionHandler:sym:name")); + } else if (wrapperType == staticmembervar) { + // Static member variable, wrapped as a function due to PHP limitations. + methodname = Char(Getattr(n, "staticmembervariableHandler:sym:name")); } else { // wrapperType == standard methodname = Char(iname); if (!s_fakeoowrappers) @@ -1053,6 +1056,7 @@ public: bool really_overloaded = overloaded ? true : false; int min_num_of_arguments = emit_num_required(l); int max_num_of_arguments = emit_num_arguments(l); + // For a function with default arguments, we end up with the fullest // parmlist in full_parmlist. ParmList *full_parmlist = l; @@ -1515,6 +1519,7 @@ public: Printf(prepare, "$this->%s=", SWIG_PTR); } } + if (!directorsEnabled() || !Swig_directorclass(n) || !newobject) { Printf(prepare, "%s(%s);\n", iname, invoke_args); } else { @@ -1594,6 +1599,26 @@ public: Printf(output, "\t%sfunction %s(%s) {\n", acc, methodname, args); } Delete(acc); + } else if (wrapperType == staticmembervar) { + // We're called twice for a writable static member variable - first + // with "foo_set" and then with "foo_get" - so generate half the + // wrapper function each time. + // + // For a const static member, we only get called once. + static bool started = false; + if (!started) { + Printf(output, "\tstatic function %s() {\n", methodname); + if (max_num_of_arguments) { + // Setter. + Printf(output, "\t\tif (func_num_args()) {\n"); + Printf(output, "\t\t\t%s(func_get_arg(0));\n", iname); + Printf(output, "\t\t\treturn;\n"); + Printf(output, "\t\t}\n"); + started = true; + goto done; + } + } + started = false; } else { Printf(output, "\tstatic function %s(%s) {\n", methodname, args); } @@ -1708,6 +1733,8 @@ public: Printf(output, "\t\treturn %s;\n", invoke); } Printf(output, "\t}\n"); + +done: Delete(prepare); Delete(invoke); free(arg_values); @@ -1720,40 +1747,6 @@ public: } free(arg_names); arg_names = NULL; - } else if (wrapperType == staticmembervar) { - // FIXME: this case ought to be folded into the one above so that it - // handles wrapping static members which are themselves objects. - - // Static member variable, wrapped as a function due to PHP limitations. - const char *methodname = 0; - String *output = s_oowrappers; - methodname = Char(Getattr(n, "staticmembervariableHandler:sym:name")); - - // We're called twice for a writable static member variable - first with - // "foo_set" and then with "foo_get" - so generate half the wrapper - // function each time. - // - // For a const static member, we only get called once. - static bool started = false; - const char *p = Char(iname); - if (strlen(p) > 4) { - p += strlen(p) - 4; - if (!started) { - started = true; - Printf(output, "\n\tstatic function %s() {\n", methodname); - if (strcmp(p, "_set") == 0) { - Printf(output, "\t\tif (func_num_args()) {\n"); - Printf(output, "\t\t\t%s(func_get_arg(0));\n", iname); - Printf(output, "\t\t\treturn;\n"); - Printf(output, "\t\t}\n"); - } - } - if (strcmp(p, "_get") == 0) { - started = false; - Printf(output, "\t\treturn %s();\n", iname); - Printf(output, "\t}\n"); - } - } } return SWIG_OK; From 719df6b10a089fbf5c6518f59e6f73a0fa0dfba7 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 15 Aug 2009 06:08:28 +0000 Subject: [PATCH 136/352] Fix pointer_reference_runme.php for PHP5 - now passes. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11579 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/pointer_reference_runme.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Examples/test-suite/php/pointer_reference_runme.php b/Examples/test-suite/php/pointer_reference_runme.php index 8fc67a134..782760a37 100644 --- a/Examples/test-suite/php/pointer_reference_runme.php +++ b/Examples/test-suite/php/pointer_reference_runme.php @@ -3,12 +3,13 @@ require "tests.php"; require "pointer_reference.php"; -$s = get(); -check::equal(Struct_value_get($s), 10, "pointer_reference.get failed"); +$s = pointer_reference::get(); +check::equal($s->value, 10, "pointer_reference::get() failed"); -$ss = new_Struct(20); -set($ss); -check::equal(Struct_value_get(Struct_instance()), 20, "pointer_reference.set failed"); +$ss = new Struct(20); +pointer_reference::set($ss); +$i = Struct::instance(); +check::equal($i->value, 20, "pointer_reference::set() failed"); check::done(); ?> From 5118c399f0516890267ba72b2b74cbade1bfba83 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 15 Aug 2009 07:39:56 +0000 Subject: [PATCH 137/352] Fix valuewrapper_base_runme.php for PHP5. Still fails though. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11580 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/valuewrapper_base_runme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/php/valuewrapper_base_runme.php b/Examples/test-suite/php/valuewrapper_base_runme.php index aff88486e..50de67f2e 100644 --- a/Examples/test-suite/php/valuewrapper_base_runme.php +++ b/Examples/test-suite/php/valuewrapper_base_runme.php @@ -7,7 +7,7 @@ require "valuewrapper_base.php"; check::classes(array("valuewrapper_base","Base","Interface_BP")); check::functions("make_interface_bp"); -$ibp=make_interface_bp(); +$ibp=valuewrapper_base::make_interface_bp(); check::classname("interface_bp",$ibp); check::done(); From d74b680a79ee9cd68b4c92f882d68693d18bac28 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Aug 2009 10:40:19 +0000 Subject: [PATCH 138/352] Fix %template seg fault on some cases of overloading the templated method. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11582 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ .../java/template_methods_runme.java | 7 ++++++ Examples/test-suite/template_methods.i | 22 +++++++++++++++++++ Source/CParse/parser.y | 2 +- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index c2ce13d66..70914fb2f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-08-15: wsfulton + Fix %template seg fault on some cases of overloading the templated method. + Bug reported by Jan Kupec. + 2009-08-15: wsfulton [Ruby] Add numerous missing wrapped methods for std::vector specialization as reported by Youssef Jones. diff --git a/Examples/test-suite/java/template_methods_runme.java b/Examples/test-suite/java/template_methods_runme.java index cc179aa49..14256b6be 100644 --- a/Examples/test-suite/java/template_methods_runme.java +++ b/Examples/test-suite/java/template_methods_runme.java @@ -32,6 +32,13 @@ public class template_methods_runme { 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/Examples/test-suite/template_methods.i b/Examples/test-suite/template_methods.i index efd7e3707..8524d5b44 100644 --- a/Examples/test-suite/template_methods.i +++ b/Examples/test-suite/template_methods.i @@ -5,6 +5,8 @@ %warnfilter(SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE) convolve1(); %warnfilter(SWIGWARN_LANG_TEMPLATE_METHOD_IGNORE) convolve3(); +%include + /////////////////// %ignore convolve1(float a); @@ -76,3 +78,23 @@ struct Klass { %template(KlassTMethodBool) Klass::tmethod; %template(KlassStaticTMethodBool) Klass::statictmethod; +//////////////////////////////////////////////////////////////////////////// + +%inline %{ + class ComponentProperties{ + public: + ComponentProperties() {} + ~ComponentProperties() {} + + template void adda(std::string key, T1 val) {} + template void adda(std::string key1, T1 val1, std::string key2, T2 val2) {} + template void adda(std::string key1, T1 val1, std::string key2, T2 val2, std::string key3, T3 val3) {} + }; +%} + +%extend ComponentProperties { + %template(adda) adda; + %template(adda) adda; // ERROR OCCURS HERE + %template(adda) adda; +} + diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index a4787bf4a..7c33e5459 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -2726,7 +2726,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va Parm *ti = targs; String *tv = Getattr(tp,"value"); if (!tv) tv = Getattr(tp,"type"); - while(pi != tp) { + while(pi != tp && ti && pi) { String *name = Getattr(ti,"name"); String *value = Getattr(pi,"value"); if (!value) value = Getattr(pi,"type"); From 4516c1d3f363a1e75b5f1548ae5e5ef199f37cec Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 15 Aug 2009 23:22:20 +0000 Subject: [PATCH 139/352] Fix exception handling when %catches is used in C# git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11583 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 7 +- Examples/test-suite/catches.i | 33 ++++++++++ Examples/test-suite/common.mk | 1 + Examples/test-suite/csharp/catches_runme.cs | 66 +++++++++++++++++++ .../csharp/exception_order_runme.cs | 48 ++++++++++++++ Lib/exception.i | 6 ++ Source/Modules/allocate.cxx | 3 +- Source/Modules/csharp.cxx | 22 +------ 8 files changed, 163 insertions(+), 23 deletions(-) create mode 100644 Examples/test-suite/catches.i create mode 100644 Examples/test-suite/csharp/catches_runme.cs create mode 100644 Examples/test-suite/csharp/exception_order_runme.cs diff --git a/CHANGES.current b/CHANGES.current index 70914fb2f..6e6295378 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.40 (in progress) ============================ +2009-08-16: wsfulton + [C#] Fix exception handling when %catches is used, reported by Juan Manuel Alvarez. + 2009-08-15: wsfulton Fix %template seg fault on some cases of overloading the templated method. Bug reported by Jan Kupec. @@ -128,8 +131,8 @@ Version 1.3.40 (in progress) Fix -Wallkw option as reported by Solomon Gibbs. 2009-07-02: wsfulton - Fix syntax error when a nested struct contains a comment containing a * followed eventually by a /. - Regression from 1.3.37, reported by Solomon Gibbs. + Fix syntax error when a nested struct contains a comment containing a * followed + eventually by a /. Regression from 1.3.37, reported by Solomon Gibbs. 2009-07-01: vmiklos [PHP] Unknown properties are no longer ignored in proxy diff --git a/Examples/test-suite/catches.i b/Examples/test-suite/catches.i new file mode 100644 index 000000000..8f09ae24c --- /dev/null +++ b/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 // 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/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 9987f3c0f..492378b16 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -117,6 +117,7 @@ CPP_TEST_CASES += \ arrays_scope \ bloody_hell \ bools \ + catches \ cast_operator \ casts \ char_strings \ diff --git a/Examples/test-suite/csharp/catches_runme.cs b/Examples/test-suite/csharp/catches_runme.cs new file mode 100644 index 000000000..2b5290eac --- /dev/null +++ b/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/Examples/test-suite/csharp/exception_order_runme.cs b/Examples/test-suite/csharp/exception_order_runme.cs new file mode 100644 index 000000000..16b32983f --- /dev/null +++ b/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/Lib/exception.i b/Lib/exception.i index e30ac1a5d..a1a47554e 100644 --- a/Lib/exception.i +++ b/Lib/exception.i @@ -262,9 +262,15 @@ SWIGINTERN void SWIG_CSharpException(int code, const char *msg) { /* rethrow the unknown exception */ +#ifdef SWIGCSHARP +%typemap(throws,noblock=1, canthrow=1) (...) { + SWIG_exception(SWIG_RuntimeError,"unknown exception"); +} +#else %typemap(throws,noblock=1) (...) { SWIG_exception(SWIG_RuntimeError,"unknown exception"); } +#endif #endif /* __cplusplus */ diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx index e8397e6a6..d78dd13d7 100644 --- a/Source/Modules/allocate.cxx +++ b/Source/Modules/allocate.cxx @@ -527,8 +527,7 @@ class Allocate:public Dispatcher { } ParmList *throws = Getattr(n, "throws"); if (throws) { - /* if there is no an explicit catchlist, - we catch everything in the throwlist */ + /* if there is no explicit catchlist, we catch everything in the throws list */ if (!catchlist) { Setattr(n, "catchlist", throws); } diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index fa76e42c8..b5444d4b4 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -898,9 +898,9 @@ public: } } - // Get any C# exception classes in the throws typemap + // Look for usage of throws typemap and the canthrow flag ParmList *throw_parm_list = NULL; - if ((throw_parm_list = Getattr(n, "throws"))) { + if ((throw_parm_list = Getattr(n, "catchlist"))) { Swig_typemap_attach_parms("throws", throw_parm_list, f); for (p = throw_parm_list; p; p = nextSibling(p)) { if ((tm = Getattr(p, "tmap:throws"))) { @@ -3063,13 +3063,6 @@ public: return tm; } - /* ----------------------------------------------------------------------------- - * addThrows() - // TODO: remove - * ----------------------------------------------------------------------------- */ - void addThrows(Node *, const String *, Node *) { - } - /* ----------------------------------------------------------------------------- * canThrow() * Determine whether the code in the typemap can throw a C# exception. @@ -3417,10 +3410,6 @@ public: Printf(arg, "j%s", ln); - /* Add various typemap's 'throws' clauses */ - addThrows(n, "tmap:directorin", p); - addThrows(n, "tmap:out", p); - /* And add to the upcall args */ if (gencomma > 0) Printf(jupcall_args, ", "); @@ -3549,9 +3538,8 @@ public: Printf(declaration, " virtual %s", target); Delete(target); - // Get any Java exception classes in the throws typemap + // Add any exception specifications to the methods in the director class ParmList *throw_parm_list = NULL; - if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) { int gencomma = 0; @@ -3562,13 +3550,10 @@ public: Swig_typemap_attach_parms("throws", throw_parm_list, 0); for (p = throw_parm_list; p; p = nextSibling(p)) { if ((tm = Getattr(p, "tmap:throws"))) { - addThrows(n, "tmap:throws", p); - if (gencomma++) { Append(w->def, ", "); Append(declaration, ", "); } - Printf(w->def, "%s", SwigType_str(Getattr(p, "type"), 0)); Printf(declaration, "%s", SwigType_str(Getattr(p, "type"), 0)); } @@ -3621,7 +3606,6 @@ public: /* Copy jresult into c_result... */ if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) { - addThrows(n, "tmap:directorout", tp); Replaceall(tm, "$input", jresult_str); Replaceall(tm, "$result", result_str); Printf(w->code, "%s\n", tm); From c7b7078dd02589e5722189f5a1f52494288ef6dc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Aug 2009 00:04:29 +0000 Subject: [PATCH 140/352] Fix classes not being added into Java method's throws clause when %catches is used git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11584 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/java/java_throws_runme.java | 10 ++++++++++ Examples/test-suite/java_throws.i | 6 +++++- Source/Modules/java.cxx | 3 ++- Source/Modules/modula3.cxx | 2 +- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6e6295378..25c5a80c3 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-08-16: wsfulton + [Java] When %catches is used, fix so that any classes specified in the "throws" + attribute of the "throws" typemap are generated into the Java method's throws clause. + 2009-08-16: wsfulton [C#] Fix exception handling when %catches is used, reported by Juan Manuel Alvarez. diff --git a/Examples/test-suite/java/java_throws_runme.java b/Examples/test-suite/java/java_throws_runme.java index 6a73ea563..370173e50 100644 --- a/Examples/test-suite/java/java_throws_runme.java +++ b/Examples/test-suite/java/java_throws_runme.java @@ -40,6 +40,16 @@ public class java_throws_runme { if (!pass) throw new RuntimeException("Test 2 failed"); + // Check the exception class in the throw typemap + 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(); diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i index b020fefcb..48a0eeabc 100644 --- a/Examples/test-suite/java_throws.i +++ b/Examples/test-suite/java_throws.i @@ -42,12 +42,16 @@ short full_of_exceptions(int num) { #if defined(_MSC_VER) #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #endif -void throw_spec_function(int value) throw (int) { throw (int)0; } +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; diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 7ed4df636..9af6fc214 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -980,7 +980,7 @@ public: // Get any Java exception classes in the throws typemap ParmList *throw_parm_list = NULL; - if ((throw_parm_list = Getattr(n, "throws"))) { + if ((throw_parm_list = Getattr(n, "catchlist"))) { Swig_typemap_attach_parms("throws", throw_parm_list, f); for (p = throw_parm_list; p; p = nextSibling(p)) { if ((tm = Getattr(p, "tmap:throws"))) { @@ -3679,6 +3679,7 @@ public: Printf(declaration, " virtual %s", target); Delete(target); + // Add any exception specifications to the methods in the director class // Get any Java exception classes in the throws typemap ParmList *throw_parm_list = NULL; diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index b9eb840f6..b14dddd22 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -1404,7 +1404,7 @@ MODULA3(): // Get any Modula 3 exception classes in the throws typemap ParmList *throw_parm_list = NULL; - if ((throw_parm_list = Getattr(n, "throws"))) { + if ((throw_parm_list = Getattr(n, "catchlist"))) { Swig_typemap_attach_parms("throws", throw_parm_list, f); Parm *p; for (p = throw_parm_list; p; p = nextSibling(p)) { From 26cc9252d948596a9e7f34817d536a611e555c0e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Aug 2009 00:09:43 +0000 Subject: [PATCH 141/352] Fix testcase comment git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11585 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/java/java_throws_runme.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/java/java_throws_runme.java b/Examples/test-suite/java/java_throws_runme.java index 370173e50..0365b69ed 100644 --- a/Examples/test-suite/java/java_throws_runme.java +++ b/Examples/test-suite/java/java_throws_runme.java @@ -40,7 +40,7 @@ public class java_throws_runme { if (!pass) throw new RuntimeException("Test 2 failed"); - // Check the exception class in the throw typemap + // Check the exception class is used with %catches pass = false; try { java_throws.catches_function(100); From db7ed25900d305c505fe0f9163ec9c9cd22f3731 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Aug 2009 19:40:29 +0000 Subject: [PATCH 142/352] fix lextype testcase when compiled as c++ as is the case with octave git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11590 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/lextype.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/lextype.i b/Examples/test-suite/lextype.i index 0c0ef66fe..083fb589d 100644 --- a/Examples/test-suite/lextype.i +++ b/Examples/test-suite/lextype.i @@ -30,13 +30,13 @@ code is not functioning properly it will fail to compile. %typemap(in) Animal () { void *space_needed = malloc(HEIGHT_$1_lextype * WIDTH_$1_lextype); - $1 = space_needed; + $1 = ($1_ltype)space_needed; } %typemap(in) Animal[2] () { void *space_needed = malloc(2 * HEIGHT_$1_lextype * WIDTH_$1_lextype); - $1 = space_needed; + $1 = ($1_ltype)space_needed; } %inline %{ From b5de6aabe57021c341c39fd2201367d16fbbd0e8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Aug 2009 20:02:22 +0000 Subject: [PATCH 143/352] more efficient python test-suite clean git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11591 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index cfb02cf2d..274d53f1d 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -139,13 +139,13 @@ endif # Clean: remove the generated .py file %.clean: - @rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py @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' @@ -168,3 +168,4 @@ hugemod: $(MAKE) hugemod_b.cpptest sh -c "time $(PYTHON) $(hugemod_runme)" sh -c "time $(PYTHON) $(hugemod_runme)" + From 8ec652b7cf990488791dfa7e5eb995af4236e5de Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Aug 2009 20:32:42 +0000 Subject: [PATCH 144/352] Suppress g++ warning when compiled as c++ (for Octave) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11592 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/enums.i | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Examples/test-suite/enums.i b/Examples/test-suite/enums.i index 3ea48b90e..00499f800 100644 --- a/Examples/test-suite/enums.i +++ b/Examples/test-suite/enums.i @@ -32,8 +32,14 @@ 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 }; From b5c49c20fd7eb79bc5cee6dc9b8691842362f071 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Aug 2009 21:44:05 +0000 Subject: [PATCH 145/352] PHP: fix for the valuewrapper_base testcase The problem is the following: before director support, the return class type of a function was hardwired. That was bad, as factory functions wanted to instantiate abstract classes, so we switched to detecting the class type based on the PHP resource type. That was good, but broke the case when for example %template(make_Interface_BP) make >; was used, as the cheap parser had no idea how to turn 'Interface_T_oss__BinaryPolarization_t' to 'make_Interface_BP'. This patch still uses the resource type detection, but in case that would result in a non-existing class, we just use the hardwired name. NOTE: This still does not fix the case when abstract classes are used with templates. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11593 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index dc7f863e3..72ba4d4eb 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1683,6 +1683,9 @@ public: } else { Printf(output, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); } + Printf(output, "\t\t\tif (!class_exists($c)) {\n"); + Printf(output, "\t\t\t\t$c = '%s';\n", Getattr(classLookup(d), "sym:name")); + Printf(output, "\t\t\t}\n"); Printf(output, "\t\t\treturn new $c($r);\n"); } else { Printf(output, "\t\t\t$c = new stdClass();\n"); From 8da18d336e91d7b76affb0539249b3b311bc3999 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Aug 2009 21:47:24 +0000 Subject: [PATCH 146/352] PHP: Optimize the previous commit a bit. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11594 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 72ba4d4eb..3c975d18b 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1684,7 +1684,7 @@ public: Printf(output, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); } Printf(output, "\t\t\tif (!class_exists($c)) {\n"); - Printf(output, "\t\t\t\t$c = '%s';\n", Getattr(classLookup(d), "sym:name")); + Printf(output, "\t\t\t\treturn new %s($r);\n", Getattr(classLookup(d), "sym:name")); Printf(output, "\t\t\t}\n"); Printf(output, "\t\t\treturn new $c($r);\n"); } else { From fc68afcf7351e3d9853533a237133ad815c9970a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Aug 2009 22:05:47 +0000 Subject: [PATCH 147/352] Octave: Caught exceptions display the type of the C++ exception instead of the generic 'c++-side threw an exception' message git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11595 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ .../test-suite/octave/exception_order_runme.m | 21 +++++++++---------- Lib/octave/octtypemaps.swg | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 25c5a80c3..a2cf82f4c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-08-16: wsfulton + [Octave] Caught exceptions display the type of the C++ exception instead of the + generic "c++-side threw an exception" message. + 2009-08-16: wsfulton [Java] When %catches is used, fix so that any classes specified in the "throws" attribute of the "throws" typemap are generated into the Java method's throws clause. diff --git a/Examples/test-suite/octave/exception_order_runme.m b/Examples/test-suite/octave/exception_order_runme.m index a5914f822..3fb2b9a50 100644 --- a/Examples/test-suite/octave/exception_order_runme.m +++ b/Examples/test-suite/octave/exception_order_runme.m @@ -6,40 +6,39 @@ a = A(); try a.foo() catch - if (!strcmp(raised(),"E1")) - error, "bad exception order" + 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(raised(),"E2")) - error, "bad exception order" + 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 - [t,e]=raised(); - if (!strcmp(e.args(0),"postcatch unknown")) - error + 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(raised(),"E1")) - error, "bad exception order" + 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(raised(),"E2")) - error, "bad exception order" + 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/Lib/octave/octtypemaps.swg b/Lib/octave/octtypemaps.swg index 7934f90bd..26a52197f 100644 --- a/Lib/octave/octtypemaps.swg +++ b/Lib/octave/octtypemaps.swg @@ -32,7 +32,7 @@ #define SWIG_SetConstant(name, obj) SWIG_Octave_SetConstant(module_ns,name,obj) // raise -#define SWIG_Octave_Raise(obj, type, desc) error("c++-side threw an exception") +#define SWIG_Octave_Raise(OBJ, TYPE, DESC) error("C++ side threw an exception of type " TYPE) #define SWIG_Raise(obj, type, desc) SWIG_Octave_Raise(obj, type, desc) // Include the unified typemap library From 4050e5e6f66b6fb71218cae2f759931c32a988ac Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Aug 2009 22:09:33 +0000 Subject: [PATCH 148/352] Add missing commit message for Xavier's Octave 3.2 support git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11596 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index a2cf82f4c..bc810f7fd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -120,6 +120,9 @@ Version 1.3.40 (in progress) different name to the class, as such constructors can still take parameters. +2009-07-12: xavier99 + [Octave] Add support for Octave 3.2 API + 2009-07-05: olly [PHP] Update the list of PHP keywords - "cfunction" is no longer a keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__", From 3cabcd05537d361cbe6d216e223f08d6979f4895 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Aug 2009 22:14:06 +0000 Subject: [PATCH 149/352] remove debug print statements git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11597 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/octave/empty_runme.m | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Examples/test-suite/octave/empty_runme.m b/Examples/test-suite/octave/empty_runme.m index 373c7b0dd..e7b64f1cd 100644 --- a/Examples/test-suite/octave/empty_runme.m +++ b/Examples/test-suite/octave/empty_runme.m @@ -1,17 +1,2 @@ empty -printf("begin\n"); -who global - -printf("after load\n"); -who global - -#clear -g -printf("after clear\n"); -who global - -#clear empty -printf("after clear specific\n"); -who global - -printf("before shutdown\n"); From 82df087b8b6855294d903650feed73167b13aff4 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 16 Aug 2009 22:23:32 +0000 Subject: [PATCH 150/352] PHP: remove '// Sample test file' comments from runme files Those are cut&pasted from skel.php, but that comment makes sense only in skel.php itself. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11598 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/add_link_runme.php | 1 - Examples/test-suite/php/arrayptr_runme.php | 1 - Examples/test-suite/php/arrays_global_runme.php | 1 - Examples/test-suite/php/arrays_global_twodim_runme.php | 1 - Examples/test-suite/php/arrays_runme.php | 1 - Examples/test-suite/php/arrays_scope_runme.php | 1 - Examples/test-suite/php/casts_runme.php | 1 - Examples/test-suite/php/class_ignore_runme.php | 1 - Examples/test-suite/php/conversion_namespace_runme.php | 1 - Examples/test-suite/php/conversion_runme.php | 1 - Examples/test-suite/php/cpp_static_runme.php | 1 - Examples/test-suite/php/director_nested_runme.php | 1 - Examples/test-suite/php/evil_diamond_ns_runme.php | 1 - Examples/test-suite/php/evil_diamond_prop_runme.php | 1 - Examples/test-suite/php/evil_diamond_runme.php | 1 - Examples/test-suite/php/extend_template_ns_runme.php | 1 - Examples/test-suite/php/extend_template_runme.php | 1 - Examples/test-suite/php/grouping_runme.php | 1 - Examples/test-suite/php/ignore_parameter_runme.php | 1 - Examples/test-suite/php/li_std_string_runme.php | 1 - Examples/test-suite/php/newobject1_runme.php | 1 - Examples/test-suite/php/prefix_runme.php | 1 - Examples/test-suite/php/rename_scope_runme.php | 1 - Examples/test-suite/php/smart_pointer_rename_runme.php | 1 - Examples/test-suite/php/sym_runme.php | 1 - Examples/test-suite/php/template_arg_typename_runme.php | 1 - Examples/test-suite/php/valuewrapper_base_runme.php | 1 - 27 files changed, 27 deletions(-) diff --git a/Examples/test-suite/php/add_link_runme.php b/Examples/test-suite/php/add_link_runme.php index 4d8c31d5e..7523bd604 100644 --- a/Examples/test-suite/php/add_link_runme.php +++ b/Examples/test-suite/php/add_link_runme.php @@ -1,5 +1,4 @@ Date: Sun, 16 Aug 2009 23:23:49 +0000 Subject: [PATCH 151/352] Fix testcase to minimal testing, most of it contained test code not relevant to std_vector.i git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11599 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/octave/li_std_vector_runme.m | 155 +----------------- 1 file changed, 3 insertions(+), 152 deletions(-) diff --git a/Examples/test-suite/octave/li_std_vector_runme.m b/Examples/test-suite/octave/li_std_vector_runme.m index b9f33ee02..83d1f2cb0 100644 --- a/Examples/test-suite/octave/li_std_vector_runme.m +++ b/Examples/test-suite/octave/li_std_vector_runme.m @@ -1,160 +1,11 @@ li_std_vector iv = IntVector(4); -for i=0:4, +for i=0:3, iv(i) = i; endfor - x = average(iv); -y = average([1,2,3,4]); -a = half([10,10.5,11,11.5]); - -dv = DoubleVector(10); -for i=0:10, - dv(i) = i/2.0; -endfor - -halve_in_place(dv); - - -bv = BoolVector(4); -bv(0)= 1; -bv(1)= 0; -bv(2)= 4; -bv(3)= 0; - -if (bv(0) != bv(2)) - error("bad std::vector mapping") +if (x != 1.5) + error("average failed"); endif - -b = B(5); -va = VecA([b,None,b,b]); - -if (va(0).f(1) != 6) - error("bad std::vector mapping") -endif - -if (vecAptr(va) != 6) - error("bad std::vector mapping") -endif - -b.val = 7; -if (va(3).f(1) != 8) - error("bad std::vector mapping") -endif - - -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)) - error("bad std::vector mapping") -endif - -delete_ArrInt(ap); - - -a = halfs([10,8,4,3]); - -v = IntVector(); -v(0:2) = [1,2]; -if (v(0) != 1 || v[1] != 2) - error("bad setslice") -endif - -if (v(0:-1)(0) != 1) - error("bad getslice") -endif - -if (v(0:-2).size() != 0) - error("bad getslice") - -v(0:1) = [2]; -if (v(0) != 2) - error("bad setslice") -endif - -v(1:) = [3]; -if (v(1) != 3) - error("bad setslice") -endif - -v(2:) = [3] -if (v(2) != 3) - error("bad setslice") -endif - -if (v(0:)(0) != v(0)) - error("bad getslice") -endif - - -v.erase(:) -if (v.size() != 0) - error("bad getslice") -endif - -v.erase(:) -if (v.size() != 0) - error("bad getslice") -endif - - - -v = vecStr({"hello ", "world"}); -if (v(0) != 'hello world') - error,"bad std::string+std::vector" -endif - - -pv = pyvector({1, "hello", (1,2)}); - -if (pv(1) != "hello") - error -endif - - -iv = IntVector(5); -for i=0:5, - iv(i) = i -endif - -iv(1:3) = []; -if (iv(1) != 3) - error -endif - -# Overloading checks -if (overloaded1(iv) != "vector") - error -endif - -if (overloaded1(dv) != "vector") - error -endif - -if (overloaded2(iv) != "vector") - error -endif - -if (overloaded2(dv) != "vector") - error -endif - -if (overloaded3(iv) != "vector *") - error -endif - -if (overloaded3(None) != "vector *") - error -endif - -if (overloaded3(100) != "int") - error -endif - From 3283728cf5fbd454b5b8dc8b4841511e0cf71fe1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 16 Aug 2009 23:25:42 +0000 Subject: [PATCH 152/352] Add semicolons to remove unwanted statement output git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11600 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/octave/imports_runme.m | 4 ++-- Examples/test-suite/octave/multi_import_runme.m | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/octave/imports_runme.m b/Examples/test-suite/octave/imports_runme.m index 3964552ab..be9db5919 100644 --- a/Examples/test-suite/octave/imports_runme.m +++ b/Examples/test-suite/octave/imports_runme.m @@ -1,7 +1,7 @@ # This is the import runtime testcase. -imports_b -imports_a +imports_b; +imports_a; x = imports_b.B(); x.hello(); diff --git a/Examples/test-suite/octave/multi_import_runme.m b/Examples/test-suite/octave/multi_import_runme.m index a6138736c..08149aae4 100644 --- a/Examples/test-suite/octave/multi_import_runme.m +++ b/Examples/test-suite/octave/multi_import_runme.m @@ -1,5 +1,5 @@ -multi_import_a -multi_import_b +multi_import_a; +multi_import_b; x = multi_import_b.XXX(); if (x.testx() != 0) From 3141dfd599f1a89c87fb71abdfe5c8b0320fd2e5 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Aug 2009 01:08:23 +0000 Subject: [PATCH 153/352] Convert to use proxy classes. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11601 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/reference/Makefile | 2 +- Examples/php/reference/example.cxx | 3 +-- Examples/php/reference/example.h | 2 +- Examples/php/reference/example.i | 3 +-- Examples/php/reference/runme.php | 43 +++++++++++++++--------------- 5 files changed, 25 insertions(+), 28 deletions(-) diff --git a/Examples/php/reference/Makefile b/Examples/php/reference/Makefile index 252a72660..1bc0beaab 100644 --- a/Examples/php/reference/Makefile +++ b/Examples/php/reference/Makefile @@ -4,7 +4,7 @@ CXXSRCS = example.cxx TARGET = example INTERFACE = example.i LIBS = -SWIGOPT = -noproxy +SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ diff --git a/Examples/php/reference/example.cxx b/Examples/php/reference/example.cxx index 3e13841d2..13e47eade 100644 --- a/Examples/php/reference/example.cxx +++ b/Examples/php/reference/example.cxx @@ -17,7 +17,7 @@ Vector operator+(const Vector &a, const Vector &b) { return r; } -char *Vector::print() { +char *Vector::as_string() { static char temp[512]; sprintf(temp,"Vector %p (%g,%g,%g)", this, x,y,z); return temp; @@ -47,4 +47,3 @@ int VectorArray::size() { printf("VectorArray: size %d self=%p\n",maxsize,this); return maxsize; } - diff --git a/Examples/php/reference/example.h b/Examples/php/reference/example.h index 4915adb1b..1b88cbf5c 100644 --- a/Examples/php/reference/example.h +++ b/Examples/php/reference/example.h @@ -7,7 +7,7 @@ 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(); + char *as_string(); }; class VectorArray { diff --git a/Examples/php/reference/example.i b/Examples/php/reference/example.i index 55d1828a8..5502a4420 100644 --- a/Examples/php/reference/example.i +++ b/Examples/php/reference/example.i @@ -12,7 +12,7 @@ class Vector { public: Vector(double x, double y, double z); ~Vector(); - char *print(); + char *as_string(); }; /* This helper function calls an overloaded operator */ @@ -41,4 +41,3 @@ public: } } }; - diff --git a/Examples/php/reference/runme.php b/Examples/php/reference/runme.php index 00aaa5298..14578cd92 100644 --- a/Examples/php/reference/runme.php +++ b/Examples/php/reference/runme.php @@ -1,18 +1,17 @@ as_string()}\n"; +print " Created b: {$b->as_string()}\n"; # ----- Call an overloaded operator ----- @@ -23,8 +22,8 @@ print " Created b: $b " . Vector_print($b) . "\n"; # It returns a new allocated object. print "Adding a+b\n"; -$c = addv($a,$b); -print " a+b =". Vector_print($c)."\n"; +$c = example::addv($a,$b); +print " a+b ={$c->as_string()}\n"; # Note: Unless we free the result, a memory leak will occur $c = None; @@ -33,46 +32,46 @@ $c = None; # Note: Using the high-level interface here print "Creating an array of vectors\n"; -$va = new_VectorArray(10); +$va = new VectorArray(10); -print " va: $va size=".VectorArray_size($va)."\n"; +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 -VectorArray_set($va,0,$a); -VectorArray_set($va,1,$b); +$va->set(0,$a); +$va->set(1,$b); -VectorArray_get($va,0); +$va->get(0); # This will work, but it will cause a memory leak! -VectorArray_set($va,2,addv($a,$b)); +$va->set(2,addv($a,$b)); # The non-leaky way to do it $c = addv($a,$b); -VectorArray_set($va,3,$c); -$c = None; +$va->set(3,$c); +$c = NULL; # Get some values from the array print "Getting some array values\n"; for ($i = 0; $i < 5; $i++) { -print "do $i\n"; - print " va($i) = ". Vector_print(VectorArray_get($va,$i)). "\n"; + print "do $i\n"; + print " va($i) = {$va->get($i)->as_string()}\n"; } # Watch under resource meter to check on this #print "Making sure we don't leak memory.\n"; #for ($i = 0; $i < 1000000; $i++) { -# $c = VectorArray_get($va,$i % 10); +# $c = $va->get($i % 10); #} # ----- Clean up ----- print "Cleaning up\n"; # wants fixing FIXME -$va = None; -$a = None; -$b = None; +$va = NULL; +$a = NULL; +$b = NULL; ?> From cd6eb83d612b5103947ed087243993fc542509f5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 17 Aug 2009 01:10:04 +0000 Subject: [PATCH 154/352] Fix #2797485 After doing a 'make clean', install fails if yodl2man or yodl2html is not available. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11602 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 4 ++-- CHANGES.current | 4 ++++ Makefile.in | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index ec55ccaf5..29cf8db1b 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -53,7 +53,7 @@ uninstall: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1 clean: /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT) -clean-docs: +distclean-docs: rm -f $(PACKAGE_NAME).1 web/ccache-man.html check : test @@ -63,7 +63,7 @@ test: test.sh check: test -distclean: clean +distclean: clean distclean-docs /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status configure config.h # FIXME: To fix this, test.sh needs to be able to take ccache from the diff --git a/CHANGES.current b/CHANGES.current index bc810f7fd..39ef5427a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-08-17: wsfulton + Fix #2797485 After doing a 'make clean', install fails if yodl2man or yodl2html + is not available. + 2009-08-16: wsfulton [Octave] Caught exceptions display the type of the C++ exception instead of the generic "c++-side threw an exception" message. diff --git a/Makefile.in b/Makefile.in index ec8cdb8be..19d37dc3b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -377,7 +377,7 @@ clean-docs-main: @test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) clean clean-docs-ccache: - @test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) clean-docs) + @# Use distclean-docs-ccache, else a user requires the yodl tools to generate the docs after a clean maintainer-clean: clean-libfiles @cd $(SOURCE) && $(MAKE) maintainer-clean @@ -404,6 +404,9 @@ distclean-test-suite: distclean-ccache: test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s distclean) +distclean-docs-ccache: + @test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) distclean-docs) + distclean-dead: rm -f $(DISTCLEAN-DEAD) From 089b226b8045582c54c0467a225e7aacc7623fea Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Aug 2009 01:27:31 +0000 Subject: [PATCH 155/352] Rename the "extend" example to "directors" as it tests directors not %extend. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11603 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/{extend => directors}/Makefile | 0 Examples/php/{extend => directors}/example.cxx | 0 Examples/php/{extend => directors}/example.h | 0 Examples/php/{extend => directors}/example.i | 0 Examples/php/{extend => directors}/index.html | 0 Examples/php/{extend => directors}/runme.php | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename Examples/php/{extend => directors}/Makefile (100%) rename Examples/php/{extend => directors}/example.cxx (100%) rename Examples/php/{extend => directors}/example.h (100%) rename Examples/php/{extend => directors}/example.i (100%) rename Examples/php/{extend => directors}/index.html (100%) rename Examples/php/{extend => directors}/runme.php (100%) diff --git a/Examples/php/extend/Makefile b/Examples/php/directors/Makefile similarity index 100% rename from Examples/php/extend/Makefile rename to Examples/php/directors/Makefile diff --git a/Examples/php/extend/example.cxx b/Examples/php/directors/example.cxx similarity index 100% rename from Examples/php/extend/example.cxx rename to Examples/php/directors/example.cxx diff --git a/Examples/php/extend/example.h b/Examples/php/directors/example.h similarity index 100% rename from Examples/php/extend/example.h rename to Examples/php/directors/example.h diff --git a/Examples/php/extend/example.i b/Examples/php/directors/example.i similarity index 100% rename from Examples/php/extend/example.i rename to Examples/php/directors/example.i diff --git a/Examples/php/extend/index.html b/Examples/php/directors/index.html similarity index 100% rename from Examples/php/extend/index.html rename to Examples/php/directors/index.html diff --git a/Examples/php/extend/runme.php b/Examples/php/directors/runme.php similarity index 100% rename from Examples/php/extend/runme.php rename to Examples/php/directors/runme.php From c9635d6255ac6260bd0f7589a00c2e74547d2c62 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Aug 2009 01:30:42 +0000 Subject: [PATCH 156/352] Remove bogus stuff about memory leaks - nothing in this testcase leaks. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11604 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/reference/example.i | 2 +- Examples/php/reference/runme.php | 42 ++++++-------------------------- 2 files changed, 8 insertions(+), 36 deletions(-) diff --git a/Examples/php/reference/example.i b/Examples/php/reference/example.i index 5502a4420..3710aed91 100644 --- a/Examples/php/reference/example.i +++ b/Examples/php/reference/example.i @@ -1,6 +1,6 @@ /* File : example.i */ -/* This file has a few "typical" uses of C++ references. */ +/* This file shows how to use %extend. */ %module example diff --git a/Examples/php/reference/runme.php b/Examples/php/reference/runme.php index 14578cd92..5d264ee43 100644 --- a/Examples/php/reference/runme.php +++ b/Examples/php/reference/runme.php @@ -7,8 +7,8 @@ require "example.php"; # ----- Object creation ----- print "Creating some objects:\n"; -$a = new Vector(3,4,5); -$b = new Vector(10,11,12); +$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"; @@ -22,15 +22,11 @@ print " Created b: {$b->as_string()}\n"; # It returns a new allocated object. print "Adding a+b\n"; -$c = example::addv($a,$b); +$c = example::addv($a, $b); print " a+b ={$c->as_string()}\n"; -# Note: Unless we free the result, a memory leak will occur -$c = None; - # ----- Create a vector array ----- -# Note: Using the high-level interface here print "Creating an array of vectors\n"; $va = new VectorArray(10); @@ -39,39 +35,15 @@ 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->get(0); -# This will work, but it will cause a memory leak! - -$va->set(2,addv($a,$b)); - -# The non-leaky way to do it - -$c = addv($a,$b); -$va->set(3,$c); -$c = NULL; +$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 "do $i\n"; - print " va($i) = {$va->get($i)->as_string()}\n"; + print " va[$i] = {$va->get($i)->as_string()}\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 = $va->get($i % 10); -#} - -# ----- Clean up ----- -print "Cleaning up\n"; -# wants fixing FIXME -$va = NULL; -$a = NULL; -$b = NULL; - ?> From c8f64ccc2e2c9e59c85614ced23a19461c901381 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Aug 2009 01:34:26 +0000 Subject: [PATCH 157/352] Explain the poor name. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11605 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/reference/example.i | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Examples/php/reference/example.i b/Examples/php/reference/example.i index 3710aed91..d6122866b 100644 --- a/Examples/php/reference/example.i +++ b/Examples/php/reference/example.i @@ -1,6 +1,10 @@ /* File : example.i */ -/* This file shows how to use %extend. */ +/* 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 From ea560a73a444478ac955de50e84a03c68e5e387e Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Aug 2009 01:37:18 +0000 Subject: [PATCH 158/352] Rename back - William wants this consistent across all the languages and it's too much work to test a global renaming. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11606 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/{directors => extend}/Makefile | 0 Examples/php/{directors => extend}/example.cxx | 0 Examples/php/{directors => extend}/example.h | 0 Examples/php/{directors => extend}/example.i | 0 Examples/php/{directors => extend}/index.html | 0 Examples/php/{directors => extend}/runme.php | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename Examples/php/{directors => extend}/Makefile (100%) rename Examples/php/{directors => extend}/example.cxx (100%) rename Examples/php/{directors => extend}/example.h (100%) rename Examples/php/{directors => extend}/example.i (100%) rename Examples/php/{directors => extend}/index.html (100%) rename Examples/php/{directors => extend}/runme.php (100%) diff --git a/Examples/php/directors/Makefile b/Examples/php/extend/Makefile similarity index 100% rename from Examples/php/directors/Makefile rename to Examples/php/extend/Makefile diff --git a/Examples/php/directors/example.cxx b/Examples/php/extend/example.cxx similarity index 100% rename from Examples/php/directors/example.cxx rename to Examples/php/extend/example.cxx diff --git a/Examples/php/directors/example.h b/Examples/php/extend/example.h similarity index 100% rename from Examples/php/directors/example.h rename to Examples/php/extend/example.h diff --git a/Examples/php/directors/example.i b/Examples/php/extend/example.i similarity index 100% rename from Examples/php/directors/example.i rename to Examples/php/extend/example.i diff --git a/Examples/php/directors/index.html b/Examples/php/extend/index.html similarity index 100% rename from Examples/php/directors/index.html rename to Examples/php/extend/index.html diff --git a/Examples/php/directors/runme.php b/Examples/php/extend/runme.php similarity index 100% rename from Examples/php/directors/runme.php rename to Examples/php/extend/runme.php From af6c65c7e6ff93b62ac5e60aee89f1940adf10bd Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Aug 2009 01:41:16 +0000 Subject: [PATCH 159/352] Add callback and extend; fix error in alphabetical ordering. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11607 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/check.list | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Examples/php/check.list b/Examples/php/check.list index 9daad455b..28c7a619f 100644 --- a/Examples/php/check.list +++ b/Examples/php/check.list @@ -1,16 +1,18 @@ # see top-level Makefile.in # (see also top-level configure.in kludge) +callback class constants cpointer disown enum +extend funcptr overloading pointer pragmas -reference proxy +reference simple sync value From c3f61e8881bdfd0d9a52e53dad881ebe5544f1c2 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Aug 2009 02:06:43 +0000 Subject: [PATCH 160/352] Add note that a previous change fixed SF#2524029. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11608 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.current b/CHANGES.current index 39ef5427a..1ca1fc818 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -43,6 +43,7 @@ Version 1.3.40 (in progress) 2009-08-13: wsfulton [PHP] Add const reference typemaps. const reference primitive types are now passed by value rather than pointer like the other target languages. + Fixes SF#2524029. 2009-08-08: wsfulton [Python] More user friendly AttributeError is raised when there are From ea578fcc8f3ea60330cabac941f6d39ea65da15d Mon Sep 17 00:00:00 2001 From: Xavier Delacour Date: Mon, 17 Aug 2009 02:49:35 +0000 Subject: [PATCH 161/352] remove failing runtime tests director_exception_runme.m and director_finalizer_runme.m git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11609 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 +- .../octave/director_exception_runme.m | 57 ------------------- .../octave/director_finalizer_runme.m | 56 ------------------ 3 files changed, 1 insertion(+), 114 deletions(-) delete mode 100644 Examples/test-suite/octave/director_exception_runme.m delete mode 100644 Examples/test-suite/octave/director_finalizer_runme.m diff --git a/CHANGES.current b/CHANGES.current index 1ca1fc818..cf0c4a63f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -125,7 +125,7 @@ Version 1.3.40 (in progress) different name to the class, as such constructors can still take parameters. -2009-07-12: xavier99 +2009-07-12: xavier98 [Octave] Add support for Octave 3.2 API 2009-07-05: olly diff --git a/Examples/test-suite/octave/director_exception_runme.m b/Examples/test-suite/octave/director_exception_runme.m deleted file mode 100644 index 3e0b23064..000000000 --- a/Examples/test-suite/octave/director_exception_runme.m +++ /dev/null @@ -1,57 +0,0 @@ -director_exception - -MyFoo=@() subclass(Foo(), - 'ping',@(self) raise(NotImplementedError("MyFoo::ping() EXCEPTION"))); - -MyFoo2=@() subclass(Foo(), - 'ping',@(self) true); - -ok = 0; - -a = MyFoo(); -b = launder(a); - -try - b.pong(); -catch - [etype,e]=raised(); - if (etype=="NotImplementedError") - ok=1; - endif -end_try_catch - -if (!ok) - error -endif - -ok = 0; - -a = MyFoo2(); -b = launder(a); - -try - b.pong(); -catch - ok = 1; -end_try_catch - -if (!ok) - error -endif - - -try - raise(Exception2()); -catch - if (!strcmp(raised,"Exception2")) - rethrow(lasterr); - endif -end_try_catch - -try - raise(Exception1()); -catch - if (!strcmp(raised,"Exception1")) - rethrow(lasterr); - endif -end_try_catch diff --git a/Examples/test-suite/octave/director_finalizer_runme.m b/Examples/test-suite/octave/director_finalizer_runme.m deleted file mode 100644 index 3781a0f77..000000000 --- a/Examples/test-suite/octave/director_finalizer_runme.m +++ /dev/null @@ -1,56 +0,0 @@ -director_finalizer - -MyFoo=@() subclass(Foo(),'__del__',@delete_MyFoo); -function delete_MyFoo(self) - self.orStatus(2); - try - Foo.__del__(self); - catch - end_try_catch -endfunction - -resetStatus(); - -a = MyFoo(); -clear a; - -if (getStatus() != 3) - error -endif - -resetStatus(); - -a = MyFoo(); -launder(a); - -if (getStatus() != 0) - error -endif - -clear a; - -if (getStatus() != 3) - error -endif - -resetStatus(); - -a = MyFoo().__disown__(); -deleteFoo(a); - -if (getStatus() != 3) - error -endif - -resetStatus(); - -a = MyFoo().__disown__(); -deleteFoo(launder(a)); - -if (getStatus() != 3) - error -endif - -resetStatus(); - - From c4f5f22f679d304e76990031f5f201434539c491 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Aug 2009 03:19:14 +0000 Subject: [PATCH 162/352] Remove some superfluous "else"s in generated PHP code. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11610 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 3c975d18b..242f99c1e 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2022,7 +2022,7 @@ done: Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s,$value);\n", SWIG_PTR); } Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_alter_newobject($this->%s,$value);\n", module, SWIG_PTR); - Printf(s_phpclasses, "\t\telse $this->%s[$var] = $value;\n", SWIG_DATA); + Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA); if (baseclass) { Printf(s_phpclasses, "\t\treturn %s%s::__set($var,$value);\n", prefix, baseclass); } @@ -2032,16 +2032,16 @@ done: Printf(s_phpclasses, "\n\tfunction __isset($var) {\n"); Printf(s_phpclasses, "\t\tif (function_exists('%s_'.$var.'_set')) return true;\n", shadow_classname); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n"); - Printf(s_phpclasses, "\t\telse return array_key_exists($var, $this->%s);\n", SWIG_DATA); + Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA); Printf(s_phpclasses, "\t}\n"); } else { Printf(s_phpclasses, "\n\tfunction __set($var,$value) {\n"); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_alter_newobject($this->%s,$value);\n", module, SWIG_PTR); - Printf(s_phpclasses, "\t\telse $this->%s[$var] = $value;\n", SWIG_DATA); + Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA); Printf(s_phpclasses, "\t}\n"); Printf(s_phpclasses, "\n\tfunction __isset($var) {\n"); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n"); - Printf(s_phpclasses, "\t\telse return array_key_exists($var, $this->%s);\n", SWIG_DATA); + Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA); Printf(s_phpclasses, "\t}\n"); } // Write property GET handlers @@ -2062,19 +2062,19 @@ done: Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_get';\n", shadow_classname); Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s);\n", SWIG_PTR); } - Printf(s_phpclasses, "\t\telse if ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR); - Printf(s_phpclasses, "\t\telse if(array_key_exists($var, $this->%s)) return $this->%s[$var];\n", SWIG_DATA, SWIG_DATA); - // Reading an unknown property name gives null in PHP. + Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR); + Printf(s_phpclasses, "\t\tif (array_key_exists($var, $this->%s)) return $this->%s[$var];\n", SWIG_DATA, SWIG_DATA); if (base.item) { Printf(s_phpclasses, "\t\treturn %s%s::__get($var);\n", prefix, baseclass); } else { + // Reading an unknown property name gives null in PHP. Printf(s_phpclasses, "\t\treturn null;\n"); } Printf(s_phpclasses, "\t}\n"); } else { Printf(s_phpclasses, "\n\tfunction __get($var) {\n"); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR); - Printf(s_phpclasses, "\t\telse return $this->%s[$var];\n", SWIG_DATA); + Printf(s_phpclasses, "\t\treturn $this->%s[$var];\n", SWIG_DATA); Printf(s_phpclasses, "\t}\n"); } From 47e404ba5b3bac3d5567038409bd885c4654ec5f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Aug 2009 05:24:17 +0000 Subject: [PATCH 163/352] Only have an array for properties in the base class, not in derived classes. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11611 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 242f99c1e..2e3f53ecf 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2001,7 +2001,11 @@ done: Append(s_phpclasses, "extends Exception "); } Printf(s_phpclasses, "{\n\tpublic $%s=null;\n", SWIG_PTR); - Printf(s_phpclasses, "\tprotected $%s=array();\n", SWIG_DATA); + if (!baseclass) { + // Only store this in the base class (NB !baseclass means we *are* + // a base class...) + Printf(s_phpclasses, "\tprotected $%s=array();\n", SWIG_DATA); + } // Write property SET handlers ki = First(shadow_set_vars); @@ -2022,9 +2026,10 @@ done: Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s,$value);\n", SWIG_PTR); } Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_alter_newobject($this->%s,$value);\n", module, SWIG_PTR); - Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA); if (baseclass) { - Printf(s_phpclasses, "\t\treturn %s%s::__set($var,$value);\n", prefix, baseclass); + Printf(s_phpclasses, "\t\t%s%s::__set($var,$value);\n", prefix, baseclass); + } else { + Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA); } Printf(s_phpclasses, "\t}\n"); @@ -2032,16 +2037,28 @@ done: Printf(s_phpclasses, "\n\tfunction __isset($var) {\n"); Printf(s_phpclasses, "\t\tif (function_exists('%s_'.$var.'_set')) return true;\n", shadow_classname); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n"); - Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA); + if (baseclass) { + Printf(s_phpclasses, "\t\treturn %s%s::__isset($var);\n", prefix, baseclass); + } else { + Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA); + } Printf(s_phpclasses, "\t}\n"); } else { Printf(s_phpclasses, "\n\tfunction __set($var,$value) {\n"); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_alter_newobject($this->%s,$value);\n", module, SWIG_PTR); - Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA); + if (baseclass) { + Printf(s_phpclasses, "\t\t%s%s::__set($var,$value);\n", prefix, baseclass); + } else { + Printf(s_phpclasses, "\t\t$this->%s[$var] = $value;\n", SWIG_DATA); + } Printf(s_phpclasses, "\t}\n"); Printf(s_phpclasses, "\n\tfunction __isset($var) {\n"); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return true;\n"); - Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA); + if (baseclass) { + Printf(s_phpclasses, "\t\treturn %s%s::__isset($var);\n", prefix, baseclass); + } else { + Printf(s_phpclasses, "\t\treturn array_key_exists($var, $this->%s);\n", SWIG_DATA); + } Printf(s_phpclasses, "\t}\n"); } // Write property GET handlers @@ -2063,18 +2080,21 @@ done: Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s);\n", SWIG_PTR); } Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR); - Printf(s_phpclasses, "\t\tif (array_key_exists($var, $this->%s)) return $this->%s[$var];\n", SWIG_DATA, SWIG_DATA); - if (base.item) { + if (baseclass) { Printf(s_phpclasses, "\t\treturn %s%s::__get($var);\n", prefix, baseclass); } else { // Reading an unknown property name gives null in PHP. - Printf(s_phpclasses, "\t\treturn null;\n"); + Printf(s_phpclasses, "\t\treturn $this->%s[$var];\n", SWIG_DATA); } Printf(s_phpclasses, "\t}\n"); } else { Printf(s_phpclasses, "\n\tfunction __get($var) {\n"); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR); - Printf(s_phpclasses, "\t\treturn $this->%s[$var];\n", SWIG_DATA); + if (baseclass) { + Printf(s_phpclasses, "\t\treturn %s%s::__get($var);\n", prefix, baseclass); + } else { + Printf(s_phpclasses, "\t\treturn $this->%s[$var];\n", SWIG_DATA); + } Printf(s_phpclasses, "\t}\n"); } From 4540717c39dcbfac35c052147244cc6f9aedb54a Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Aug 2009 08:47:30 +0000 Subject: [PATCH 164/352] [PHP] Fix to wrap a resource returned by __get() in a PHP object (SF#2549217). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11619 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/php.cxx | 23 +++++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index cf0c4a63f..2dca20083 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.40 (in progress) ============================ +2009-08-17: olly + [PHP] Fix to wrap a resource returned by __get() in a PHP object (SF#2549217). + 2009-08-17: wsfulton Fix #2797485 After doing a 'make clean', install fails if yodl2man or yodl2html is not available. diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index 2e3f53ecf..bae922e90 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2067,18 +2067,21 @@ done: if (ki.key) { // This class has getters. Printf(s_phpclasses, "\n\tfunction __get($var) {\n"); - // FIXME: tune this threshold... - if (Len(shadow_get_vars) <= 2) { - // Not many getters, so avoid call_user_func. - while (ki.key) { - key = ki.key; - Printf(s_phpclasses, "\t\tif ($var === '%s') return %s($this->%s);\n", key, ki.item, SWIG_PTR); - ki = Next(ki); - } + // FIXME: Currently we always use call_user_func for __get, so we can + // check and wrap the result. This is needless if all the properties + // are primitive types. Also this doesn't handle all the cases which + // a method returning an object does. + Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_get';\n", shadow_classname); + Printf(s_phpclasses, "\t\tif (function_exists($func)) {\n"); + Printf(s_phpclasses, "\t\t\t$r = call_user_func($func,$this->%s);\n", SWIG_PTR); + Printf(s_phpclasses, "\t\t\tif (!is_resource($r)) return $r;\n"); + if (Len(prefix) == 0) { + Printf(s_phpclasses, "\t\t\t$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n"); } else { - Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_get';\n", shadow_classname); - Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s);\n", SWIG_PTR); + Printf(s_phpclasses, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); } + Printf(s_phpclasses, "\t\t\treturn new $c($r);\n"); + Printf(s_phpclasses, "\t\t}\n"); Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR); if (baseclass) { Printf(s_phpclasses, "\t\treturn %s%s::__get($var);\n", prefix, baseclass); From 2b4c96235905e0d8e206f64ac34d25fdc299877d Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Aug 2009 12:06:08 +0000 Subject: [PATCH 165/352] [Perl] Add "#undef do_exec" to our clean up of Perl global namespace pollution. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11620 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/perl5/noembed.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 2dca20083..1021106f1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.40 (in progress) ============================ +2009-08-17: olly + [Perl] Add "#undef do_exec" to our clean up of Perl global + namespace pollution. + 2009-08-17: olly [PHP] Fix to wrap a resource returned by __get() in a PHP object (SF#2549217). diff --git a/Lib/perl5/noembed.h b/Lib/perl5/noembed.h index 55c3752aa..572465490 100644 --- a/Lib/perl5/noembed.h +++ b/Lib/perl5/noembed.h @@ -7,6 +7,9 @@ #ifdef do_close #undef do_close #endif +#ifdef do_exec + #undef do_exec +#endif #ifdef scalar #undef scalar #endif From dddec445fddf3bd3cceeac77c82725e8c323734a Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 17 Aug 2009 12:14:32 +0000 Subject: [PATCH 166/352] Start "What's New?" list for 1.3.40. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11621 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README b/README index 5fde83996..6ee379786 100644 --- a/README +++ b/README @@ -92,6 +92,10 @@ A SWIG FAQ and other hints can be found on the SWIG Wiki: What's New? =========== +SWIG-1.3.40 summary: +- SWIG now supports directors for PHP. +- PHP support improved in general. + SWIG-1.3.39 summary: - Some new small feature enhancements. - Improved C# std::vector wrappers. From b75c60620535f1716873fd26c5205b0379fae237 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 17 Aug 2009 23:07:16 +0000 Subject: [PATCH 167/352] Fix for r11557 rename of max to maximum git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11628 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/lua/overload_template_fast_runme.lua | 4 ++-- Examples/test-suite/octave/overload_template_fast_runme.m | 4 ++-- Examples/test-suite/python/overload_template_fast_runme.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/lua/overload_template_fast_runme.lua b/Examples/test-suite/lua/overload_template_fast_runme.lua index 97078f34d..6663cb0b5 100644 --- a/Examples/test-suite/lua/overload_template_fast_runme.lua +++ b/Examples/test-suite/lua/overload_template_fast_runme.lua @@ -2,12 +2,12 @@ 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 max(int,int) and max(double,double) are the same +-- 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 = max(3,4) +a = maximum(3,4) -- mix 1 assert(mix1("hi") == 101) diff --git a/Examples/test-suite/octave/overload_template_fast_runme.m b/Examples/test-suite/octave/overload_template_fast_runme.m index 346af7242..f99ce8642 100644 --- a/Examples/test-suite/octave/overload_template_fast_runme.m +++ b/Examples/test-suite/octave/overload_template_fast_runme.m @@ -5,8 +5,8 @@ overload_template_fast f = foo(); -a = max(3,4); -b = max(3.4,5.2); +a = maximum(3,4); +b = maximum(3.4,5.2); # mix 1 if (mix1("hi") != 101) diff --git a/Examples/test-suite/python/overload_template_fast_runme.py b/Examples/test-suite/python/overload_template_fast_runme.py index a8d271d27..d47f7d14d 100644 --- a/Examples/test-suite/python/overload_template_fast_runme.py +++ b/Examples/test-suite/python/overload_template_fast_runme.py @@ -1,8 +1,8 @@ from overload_template_fast import * f = foo() -a = max(3,4) -b = max(3.4,5.2) +a = maximum(3,4) +b = maximum(3.4,5.2) # mix 1 if (mix1("hi") != 101): From d2fe155495de7b6f857a66734ae71dfa93981678 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 17 Aug 2009 23:12:54 +0000 Subject: [PATCH 168/352] warning fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11629 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/special_variable_macros.i | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/special_variable_macros.i b/Examples/test-suite/special_variable_macros.i index 3f0cd724a..f27bbd619 100644 --- a/Examples/test-suite/special_variable_macros.i +++ b/Examples/test-suite/special_variable_macros.i @@ -88,7 +88,7 @@ const char * testMary(Name *mary) { %{ /*%typemap(in) (Name *multiname, int num) start */ temp_name = $*1_ltype("multiname num"); - temp_count = strlen(temp_name.getNamePtr()->getName()); + temp_count = (int)strlen(temp_name.getNamePtr()->getName()); (void)$input; $1 = temp_name.getNamePtr(); $2 = temp_count + 100; @@ -103,7 +103,7 @@ $typemap(in, (Name *multiname, int num)) %inline %{ const char * testJim(Name *jim, int count) { - if (count != strlen(jim->getNamePtr()->getName()) + 100) + if (count != (int)strlen(jim->getNamePtr()->getName()) + 100) return "size check failed"; else return jim->getName(); From 96cd19f86b6510238c5051e31862d369496e8037 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Aug 2009 00:16:11 +0000 Subject: [PATCH 169/352] Remove C# 3.0 requirement to run test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11630 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/csharp/li_std_vector_runme.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/csharp/li_std_vector_runme.cs b/Examples/test-suite/csharp/li_std_vector_runme.cs index a2da91e15..617116d5a 100644 --- a/Examples/test-suite/csharp/li_std_vector_runme.cs +++ b/Examples/test-suite/csharp/li_std_vector_runme.cs @@ -158,7 +158,8 @@ public class li_std_vector_runme { } catch (ArgumentNullException) { } { - myDoubleVector = new DoubleVector() { 123.4, 567.8, 901.2 }; + // Collection initializer test, requires C# 3.0 +// myDoubleVector = new DoubleVector() { 123.4, 567.8, 901.2 }; } // IndexOf() test @@ -542,8 +543,8 @@ public class li_std_vector_runme { // Dispose() { - using (StructVector vs = new StructVector() { new Struct(0.0), new Struct(11.1) } ) - using (DoubleVector vd = new DoubleVector() { 0.0, 11.1 } ) { + 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 } ) ) { } } From 6a5a5f69a14d08e9741e2f6a88dc681e45db9b7f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Aug 2009 01:26:56 +0000 Subject: [PATCH 170/352] Complete summary for 1.3.40 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11631 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README b/README index 6ee379786..634ec1b4d 100644 --- a/README +++ b/README @@ -95,6 +95,10 @@ What's New? SWIG-1.3.40 summary: - SWIG now supports directors for PHP. - PHP support improved in general. +- Octave 3.2 support added. +- Various bug fixes/enhancements for Allegrocl C#, Java, Octave, Perl, + Python, Ruby and Tcl. +- Other generic fixes and minor new features. SWIG-1.3.39 summary: - Some new small feature enhancements. From 2d27a4296bc7774e595e2975a30317ebcea43054 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Aug 2009 13:41:22 +0000 Subject: [PATCH 171/352] fix warnings git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11632 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/li_reference.i | 40 +++++++++++++++--------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/Examples/test-suite/li_reference.i b/Examples/test-suite/li_reference.i index d021e807f..f16fdbeaa 100644 --- a/Examples/test-suite/li_reference.i +++ b/Examples/test-suite/li_reference.i @@ -10,43 +10,43 @@ void RDouble(double &REFERENCE, int t = 0) { ToVal = REFERENCE; REFERENCE = FrVal + t; } void PFloat(float *REFERENCE, int t = 0) - { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + { ToVal = *REFERENCE; *REFERENCE = (float)(FrVal + t); } void RFloat(float &REFERENCE, int t = 0) - { ToVal = REFERENCE; REFERENCE = FrVal + t; } + { ToVal = REFERENCE; REFERENCE = (float)(FrVal + t); } void PInt(int *REFERENCE, int t = 0) - { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + { ToVal = *REFERENCE; *REFERENCE = (int)(FrVal + t); } void RInt(int &REFERENCE, int t = 0) - { ToVal = REFERENCE; REFERENCE = FrVal + t; } + { ToVal = REFERENCE; REFERENCE = (int)(FrVal + t); } void PShort(short *REFERENCE, int t = 0) - { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + { ToVal = *REFERENCE; *REFERENCE = (short)(FrVal + t); } void RShort(short &REFERENCE, int t = 0) - { ToVal = REFERENCE; REFERENCE = FrVal + t; } + { ToVal = REFERENCE; REFERENCE = (short)(FrVal + t); } void PLong(long *REFERENCE, int t = 0) - { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + { ToVal = *REFERENCE; *REFERENCE = (long)(FrVal + t); } void RLong(long &REFERENCE, int t = 0) - { ToVal = REFERENCE; REFERENCE = FrVal + t; } + { ToVal = REFERENCE; REFERENCE = (long)(FrVal + t); } void PUInt(unsigned int *REFERENCE, int t = 0) - { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + { ToVal = *REFERENCE; *REFERENCE = (unsigned int)(FrVal + t); } void RUInt(unsigned int &REFERENCE, int t = 0) - { ToVal = REFERENCE; REFERENCE = FrVal + t; } + { ToVal = REFERENCE; REFERENCE = (unsigned int)(FrVal + t); } void PUShort(unsigned short *REFERENCE, int t = 0) - { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + { ToVal = *REFERENCE; *REFERENCE = (unsigned short)(FrVal + t); } void RUShort(unsigned short &REFERENCE, int t = 0) - { ToVal = REFERENCE; REFERENCE = FrVal + t; } + { ToVal = REFERENCE; REFERENCE = (unsigned short)(FrVal + t); } void PULong(unsigned long *REFERENCE, int t = 0) - { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + { ToVal = *REFERENCE; *REFERENCE = (unsigned long)(FrVal + t); } void RULong(unsigned long &REFERENCE, int t = 0) - { ToVal = REFERENCE; REFERENCE = FrVal + t; } + { ToVal = REFERENCE; REFERENCE = (unsigned long)(FrVal + t); } void PUChar(unsigned char *REFERENCE, int t = 0) - { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + { ToVal = *REFERENCE; *REFERENCE = (unsigned char)(FrVal + t); } void RUChar(unsigned char &REFERENCE, int t = 0) - { ToVal = REFERENCE; REFERENCE = FrVal + t; } + { ToVal = REFERENCE; REFERENCE = (unsigned char)(FrVal + t); } void PChar(signed char *REFERENCE, int t = 0) - { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + { ToVal = *REFERENCE; *REFERENCE = (signed char)(FrVal + t); } void RChar(signed char &REFERENCE, int t = 0) - { ToVal = REFERENCE; REFERENCE = FrVal + t; } + { ToVal = REFERENCE; REFERENCE = (signed char)(FrVal + t); } void PBool(bool *REFERENCE, int t = 0) - { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + { ToVal = *REFERENCE; *REFERENCE = (FrVal + t) ? true : false; } void RBool(bool &REFERENCE, int t = 0) - { ToVal = REFERENCE; REFERENCE = FrVal + t; } + { ToVal = REFERENCE; REFERENCE = (FrVal + t) ? true : false; } %} From 3c604b402dce9d1febf1de672d33ffe950139c8a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 18 Aug 2009 13:47:27 +0000 Subject: [PATCH 172/352] PHP: remove unneeded ctor from the director_extend testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11633 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/director_extend_runme.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Examples/test-suite/php/director_extend_runme.php b/Examples/test-suite/php/director_extend_runme.php index f282df17d..f283aefbe 100644 --- a/Examples/test-suite/php/director_extend_runme.php +++ b/Examples/test-suite/php/director_extend_runme.php @@ -11,11 +11,6 @@ check::classes(array(SpObject)); check::globals(array()); class MyObject extends SpObject{ - function __construct() { - parent::__construct(); - return; - } - function getFoo() { return 123; } From 4be26aa11d967501c8a5f6de65555c46d7fab387 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Aug 2009 14:02:22 +0000 Subject: [PATCH 173/352] Clear up confusion that typemaps can contain C/C++ as well as target language code git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11634 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Sections.html | 2 +- Doc/Manual/Typemaps.html | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 789efc129..e39633e38 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

        SWIG-1.3 Development Documentation

        -Last update : SWIG-1.3.40 (in progress) +Last update : SWIG-1.3.40 (18 August 2009)

        Sections

        diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 226b4ef3e..bf31b30b9 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -230,14 +230,17 @@ At first glance, this code will look a little confusing. However, there is really not much to it. The first typemap (the "in" typemap) is used to convert a value from the target language to C. The second typemap (the "out" typemap) is used to convert in the other -direction. The content of each typemap is a small fragment of C code -that is inserted directly into the SWIG generated wrapper functions. Within -this code, a number of special variables prefixed with a $ are expanded. These are -really just placeholders for C variables that are generated in the course +direction. The content of each typemap is a small fragment of code +that is inserted directly into the SWIG generated wrapper functions. +The code is usually C or C++ code which will be generated into the C/C++ wrapper functions. +Note that this isn't always the case as some target language modules allow target language +code within the typemaps which gets generated into target language specific files. +Within this code, a number of special variables prefixed with a $ are expanded. These are +really just placeholders for C/C++ variables that are generated in the course of creating the wrapper function. In this case, $input refers to an -input object that needs to be converted to C and $result +input object that needs to be converted to C/C++ and $result refers to an object that is going to be returned by a wrapper -function. $1 refers to a C variable that has the same type as +function. $1 refers to a C/C++ variable that has the same type as specified in the typemap declaration (an int in this example).

        @@ -4060,6 +4063,7 @@ numerous examples. You should look at these files to get a feel for how to define typemaps of your own. Some of the language modules support additional typemaps and further information is available in the individual chapters for each target language. +There you may also find more hands-on practical examples.

        From 66e281e7f0a5cade4a4f671133b3c86fc40006d3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Aug 2009 14:04:06 +0000 Subject: [PATCH 174/352] add 1.3.40 release date git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11635 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 2 +- CHANGES.current | 4 ++-- README | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 9ef41142a..64e195d04 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 1.3.40 (in progress) *** +*** ANNOUNCE: SWIG 1.3.40 (18 August 2009) *** http://www.swig.org diff --git a/CHANGES.current b/CHANGES.current index 1021106f1..e41f17d65 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,5 @@ -Version 1.3.40 (in progress) -============================ +Version 1.3.40 (18 August 2009) +=============================== 2009-08-17: olly [Perl] Add "#undef do_exec" to our clean up of Perl global diff --git a/README b/README index 634ec1b4d..dbf438f51 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.40 (in progress) +Version: 1.3.40 (18 August 2009) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, @@ -96,7 +96,7 @@ SWIG-1.3.40 summary: - SWIG now supports directors for PHP. - PHP support improved in general. - Octave 3.2 support added. -- Various bug fixes/enhancements for Allegrocl C#, Java, Octave, Perl, +- Various bug fixes/enhancements for Allegrocl, C#, Java, Octave, Perl, Python, Ruby and Tcl. - Other generic fixes and minor new features. From f0fb2f38518674b973bb97552b89ec84e94c003e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Aug 2009 14:08:50 +0000 Subject: [PATCH 175/352] Remove 'under construction' notes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11636 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Arguments.html | 2 -- Doc/Manual/Php.html | 4 ---- Doc/Manual/Typemaps.html | 4 ---- 3 files changed, 10 deletions(-) diff --git a/Doc/Manual/Arguments.html b/Doc/Manual/Arguments.html index 911e8548e..8ab51faf6 100644 --- a/Doc/Manual/Arguments.html +++ b/Doc/Manual/Arguments.html @@ -30,8 +30,6 @@ -Disclaimer: This chapter is under construction. -

        In Chapter 3, SWIG's treatment of basic datatypes and pointers was described. In particular, primitive types such as int and diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index 7bf158918..de745e135 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -48,10 +48,6 @@ -

        -Caution: This chapter (and module!) is still under construction -

        -

        SWIG supports generating wrappers for PHP5. Support for PHP4 has been removed as of SWIG 1.3.37. The PHP developers are no longer making new PHP4 releases, diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index bf31b30b9..da4fdadc9 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -88,10 +88,6 @@ -

        -Disclaimer: This chapter is under construction! -

        -

        10.1 Introduction

        From fc52ca3b80434eee001745e93c07cbf0fb7095cf Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 18 Aug 2009 16:23:23 +0000 Subject: [PATCH 176/352] PHP: handle -prefix when checking if a class has been subclassed or not git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11637 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index bae922e90..eee4d1fcc 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1636,7 +1636,7 @@ public: } else { Node *parent = Swig_methodclass(n); String *classname = Swig_class_name(parent); - Printf(output, "\t\tif (get_class($this) === '%s') {\n", classname); + Printf(output, "\t\tif (get_class($this) === '%s%s') {\n", prefix, classname); Printf(output, "\t\t\t$_this = null;\n"); Printf(output, "\t\t} else {\n"); Printf(output, "\t\t\t$_this = $this;\n"); From 2d78a12b873468c7d5f9529e79e445d82351a892 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 18 Aug 2009 23:30:59 +0000 Subject: [PATCH 177/352] changes required for new SourceForge file release process git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11645 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Tools/mkrelease.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py index edf3b07fe..b719c470e 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # This script builds the SWIG source tarball, creates the Windows executable and the Windows zip package -# and uploads them both to SF ready for release +# and uploads them both to SF ready for release. Also uploaded are the release notes. import sys import string import os @@ -30,10 +30,20 @@ os.system("python ./mkdist.py " + version) and failed("") print "Build Windows package" os.system("./mkwindows.sh " + version) and failed("") -print "Uploading to Sourceforge" -os.system("rsync --archive --verbose -P --times -e ssh swig-" + version + ".tar.gz " + username + "@frs.sourceforge.net:uploads/") and failed("") -os.system("rsync --archive --verbose -P --times -e ssh swigwin-" + version + ".zip " + username + "@frs.sourceforge.net:uploads/") and failed("") +print "Uploading to SourceForge" + +swig_dir_sf = username + ",swig@frs.sourceforge.net:/home/frs/project/s/sw/swig/swig/swig-" + version + "/" +swigwin_dir_sf = username + ",swig@frs.sourceforge.net:/home/frs/project/s/sw/swig/swigwin/swigwin-" + version + "/" + +release_notes_file = "release-notes-" + version + ".txt" +os.system("rm -f " + release_notes_file) +os.system("cat swig-" + version + "/README " + "swig-" + version + "/CHANGES.current > " + release_notes_file) + +os.system("rsync --archive --verbose -P --times -e ssh " + "swig-" + version + ".tar.gz " + release_notes_file + " " + swig_dir_sf) and failed("") +os.system("rsync --archive --verbose -P --times -e ssh " + "swigwin-" + version + ".zip " + swigwin_dir_sf) and failed("") os.system("svn copy -m \"rel-" + version + "\" https://swig.svn.sourceforge.net/svnroot/swig/trunk https://swig.svn.sourceforge.net/svnroot/swig/tags/rel-" + version + "/") print "Finished" + +print "Now log in to SourceForge and set the operating system and link the release notes to each of the tarball and zip file in the File Manager." From 4835720f5a63a822292e66aa0fb308a6ac1144f9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 19 Aug 2009 00:11:29 +0000 Subject: [PATCH 178/352] bump version to 1.3.41 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11647 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 10 +- CHANGES | 258 +++++++++++++++++++++++++++++++++++++++ CHANGES.current | 258 +-------------------------------------- Doc/Manual/Sections.html | 2 +- README | 2 +- configure.in | 2 +- 6 files changed, 268 insertions(+), 264 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 64e195d04..770df1b20 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,10 +1,10 @@ -*** ANNOUNCE: SWIG 1.3.40 (18 August 2009) *** +*** ANNOUNCE: SWIG 1.3.41 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-1.3.40, the latest installment in the -SWIG development effort. SWIG-1.3.40 includes a number of bug fixes +We're pleased to announce SWIG-1.3.41, the latest installment in the +SWIG development effort. SWIG-1.3.41 includes a number of bug fixes and enhancements. What is SWIG? @@ -24,11 +24,11 @@ Availability: ------------- The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-1.3.40.tar.gz + http://prdownloads.sourceforge.net/swig/swig-1.3.41.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-1.3.40.zip + http://prdownloads.sourceforge.net/swig/swigwin-1.3.41.zip Please report problems with this release to the swig-dev mailing list, details at http://www.swig.org/mail.html. diff --git a/CHANGES b/CHANGES index d9426512b..8360207c2 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,264 @@ SWIG (Simplified Wrapper and Interface Generator) See CHANGES.current for current version. +Version 1.3.40 (in progress) +=============================== + +2009-08-17: olly + [Perl] Add "#undef do_exec" to our clean up of Perl global + namespace pollution. + +2009-08-17: olly + [PHP] Fix to wrap a resource returned by __get() in a PHP object (SF#2549217). + +2009-08-17: wsfulton + Fix #2797485 After doing a 'make clean', install fails if yodl2man or yodl2html + is not available. + +2009-08-16: wsfulton + [Octave] Caught exceptions display the type of the C++ exception instead of the + generic "c++-side threw an exception" message. + +2009-08-16: wsfulton + [Java] When %catches is used, fix so that any classes specified in the "throws" + attribute of the "throws" typemap are generated into the Java method's throws clause. + +2009-08-16: wsfulton + [C#] Fix exception handling when %catches is used, reported by Juan Manuel Alvarez. + +2009-08-15: wsfulton + Fix %template seg fault on some cases of overloading the templated method. + Bug reported by Jan Kupec. + +2009-08-15: wsfulton + [Ruby] Add numerous missing wrapped methods for std::vector specialization + as reported by Youssef Jones. + +2009-08-14: wsfulton + [Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer + memory ownership control. shared_ptr support still to be added. Patch from + David Fletcher. + +2009-08-14: olly + [PHP] PHP5 now wraps static member variables as documented. + +2009-08-14: olly + [PHP] Update the PHP "class" example to work with PHP5 and use + modern wrapping features. + +2009-08-13: wsfulton + [PHP] std::vector wrappers overhaul. They no longer require the + specialize_std_vector() macro. Added wrappers for capacity() and reserve(). + +2009-08-13: wsfulton + [PHP] Add const reference typemaps. const reference primitive types are + now passed by value rather than pointer like the other target languages. + Fixes SF#2524029. + +2009-08-08: wsfulton + [Python] More user friendly AttributeError is raised when there are + no constructors generated for the proxy class in the event that the + class is abstract - the error message is now + "No constructor defined - class is abstract" whereas if there are no + public constructors for any other reason and the class is not abstract, + the message remains + "No constructor defined". + [tcl] Similarly for tcl when using -itcl. + +2009-08-04: olly + [PHP] Fix generated code to work with PHP 5.3. + +2009-08-04: vmiklos + [PHP] Various mathematical functions (which would conflict + with the built-in PHP ones) are now automatically handled by + adding a 'c_' prefix. + +2009-08-03: wsfulton + [C#] The std::vector implementation is improved and now uses $typemap such + that the proxy class for T no longer has to be specified in some macros + for correct C# compilation; the following macros are deprecated, where + CSTYPE was the C# type for the C++ class CTYPE: + + SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE) + usage should be removed altogether + + SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE) + should be replaced with: + SWIG_STD_VECTOR_ENHANCED(CTYPE) + + Some more details in csharp/std_vector.i + + *** POTENTIAL INCOMPATIBILITY *** + +2009-07-31: olly + [Python] Fix indentation so that we give a useful error if the + module can't be loaded. Patch from Gaetan Lehmann in SF#2829853. + +2009-07-29: wsfulton + Add $typemap(method, typelist) special variable macro. This allows + the contents of a typemap to be inserted within another typemap. + Fully documented in Typemaps.html. + +2009-07-29: vmiklos + [PHP] Static member variables are now prefixed with the + class name. This allows static member variables with the + same name in different classes. + +2009-07-29: olly + [Python] Add missing locks to std::map wrappers. Patch from + Paul Hampson in SF#2813836. + +2009-07-29: olly + [PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi + Amano in SF#2826322. + +2009-07-29: olly + [PHP] Fix memory leak in PHP resource destructor for classes + without a destructor and non-class types. Patch from Hitoshi Amano + in SF#2825303. + +2009-07-28: olly + [PHP] Update warnings about clashes between identifiers and PHP + keywords and automatic renaming to work with the PHP5 class + wrappers. Fixes SF#1613679. + +2009-07-28: vmiklos + [PHP] If a member function is not public but it has a base + which is public, then now a warning is issued and the member + function will be public, as PHP requires this. + +2009-07-21: vmiklos + [PHP] Director support added. + +2009-07-15: olly + [Perl] Don't specify Perl prototype "()" for a constructor with a + different name to the class, as such constructors can still take + parameters. + +2009-07-12: xavier98 + [Octave] Add support for Octave 3.2 API + +2009-07-05: olly + [PHP] Update the list of PHP keywords - "cfunction" is no longer a + keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__", + and "__NAMESPACE__". + +2009-07-03: olly + [Tcl] To complement USE_TCL_STUBS, add support for USE_TK_STUBS + and SWIG_TCL_STUBS_VERSION. Document all three in the Tcl chapter + of the manual. Based on patch from SF#2810380 by Christian + Gollwitzer. + +2009-07-02: vmiklos + [PHP] Added factory.i for PHP, see the li_factory testcase + for more info on how to use it. + +2009-07-02: wsfulton + Fix -Wallkw option as reported by Solomon Gibbs. + +2009-07-02: wsfulton + Fix syntax error when a nested struct contains a comment containing a * followed + eventually by a /. Regression from 1.3.37, reported by Solomon Gibbs. + +2009-07-01: vmiklos + [PHP] Unknown properties are no longer ignored in proxy + classes. + +2009-07-01: vmiklos + [PHP] Fixed %newobject behaviour, previously any method + marked with %newobject was handled as a constructor. + +2009-06-30: olly + [Ruby] Undefine close and connect macros defined by Ruby API + headers as we don't need them and they can clash with C++ methods + being wrapped. Patch from Vit Ondruch in SF#2814430. + +2009-06-26: olly + [Ruby] Fix to handle FIXNUM values greater than MAXINT passed for a + double parameter. + +2009-06-24: wsfulton + Fix wrapping methods with default arguments and the compactdefaultargs feature + where a class is passed by value and is assigned a default value. The SwigValueWrapper + template workaround for a missing default constructor is no longer used as the code + generated does not call the default constructor. + +2009-06-16: wsfulton + [Java,C#] Fix enum marshalling when %ignore is used on one of the enum items. + Incorrect enum values were being passed to the C++ layer or compilation errors resulted. + +2009-06-02: talby + [Perl] Resolved reference.i overload support problem + identified by John Potowsky. + +2009-05-26: wsfulton + [C#] Improved std::map wrappers based on patch from Yuval Baror. The C# proxy + now implements System.Collections.Generic.IDictionary<>. + + These std:map wrappers have a non-backwards compatible overhaul to make them + like a .NET IDictionary. Some method names have changed as following: + set -> setitem (use this[] property now) + get -> getitem (use this[] property now) + has_key -> ContainsKey + del -> Remove + clear -> Clear + + The following macros used for std::map wrappers are deprecated and will no longer work: + specialize_std_map_on_key + specialize_std_map_on_value + specialize_std_map_on_both + + *** POTENTIAL INCOMPATIBILITY *** + +2009-05-20: vmiklos + [PHP] Add the 'thisown' member to classes. The usage of it + is the same as the Python thisown one: it's 1 by default and + you can set it to 0 if you want to prevent freeing it. (For + example to prevent a double free.) + +2009-05-14: bhy + [Python] Fix the wrong pointer value returned by SwigPyObject_repr(). + +2009-05-13: mutandiz (Mikel Bancroft) + [allegrocl] Minor tweak when wrapping in -nocwrap mode. + +2009-05-11: wsfulton + [C#] Improved std::vector wrappers on the C# proxy side from Yuval Baror. These + implement IList<> instead of IEnumerable<> where possible. + +2009-04-29: wsfulton + [Java, C#] Add the 'notderived' attribute to the javabase and csbase typemaps. + When this attribute is set, the typemap will not apply to classes that are derived + from a C++ base class, eg + %typemap(csbase, notderived="1") SWIGTYPE "CommonBase" + +2009-04-29: olly + [Python] Don't attempt to acquire the GIL in situations where we + know that it will already be locked. This avoids some dead-locks + with mod_python (due to mod_python bugs which are apparently + unlikely to ever be fixed), and results in smaller wrappers which + run a little faster (in tests with Xapian on x86-64 Ubuntu 9.04, + the stripped wrapper library was 11% smaller and ran 2.7% faster). + +2009-04-21: wsfulton + [C#] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation. + +2009-04-09: wsfulton + Fix #2746858 - C macro expression using floating point numbers + +2009-03-30: olly + [PHP] The default out typemap for char[ANY] now returns the string up to a + zero byte, or the end of the array if there is no zero byte. This + is the same as Python does, and seems more generally useful than + the previous behaviour of returning the whole contents of the array + including any zero bytes. If you want the old behaviour, you can provide + your own typemap to do this: + + %typemap(out) char [ANY] + %{ + RETVAL_STRINGL($1, $1_dim0, 1); + %} + Version 1.3.39 (21 March 2009) ============================== diff --git a/CHANGES.current b/CHANGES.current index e41f17d65..99cade363 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,257 +1,3 @@ -Version 1.3.40 (18 August 2009) -=============================== +Version 1.3.41 (in progress) +============================ -2009-08-17: olly - [Perl] Add "#undef do_exec" to our clean up of Perl global - namespace pollution. - -2009-08-17: olly - [PHP] Fix to wrap a resource returned by __get() in a PHP object (SF#2549217). - -2009-08-17: wsfulton - Fix #2797485 After doing a 'make clean', install fails if yodl2man or yodl2html - is not available. - -2009-08-16: wsfulton - [Octave] Caught exceptions display the type of the C++ exception instead of the - generic "c++-side threw an exception" message. - -2009-08-16: wsfulton - [Java] When %catches is used, fix so that any classes specified in the "throws" - attribute of the "throws" typemap are generated into the Java method's throws clause. - -2009-08-16: wsfulton - [C#] Fix exception handling when %catches is used, reported by Juan Manuel Alvarez. - -2009-08-15: wsfulton - Fix %template seg fault on some cases of overloading the templated method. - Bug reported by Jan Kupec. - -2009-08-15: wsfulton - [Ruby] Add numerous missing wrapped methods for std::vector specialization - as reported by Youssef Jones. - -2009-08-14: wsfulton - [Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer - memory ownership control. shared_ptr support still to be added. Patch from - David Fletcher. - -2009-08-14: olly - [PHP] PHP5 now wraps static member variables as documented. - -2009-08-14: olly - [PHP] Update the PHP "class" example to work with PHP5 and use - modern wrapping features. - -2009-08-13: wsfulton - [PHP] std::vector wrappers overhaul. They no longer require the - specialize_std_vector() macro. Added wrappers for capacity() and reserve(). - -2009-08-13: wsfulton - [PHP] Add const reference typemaps. const reference primitive types are - now passed by value rather than pointer like the other target languages. - Fixes SF#2524029. - -2009-08-08: wsfulton - [Python] More user friendly AttributeError is raised when there are - no constructors generated for the proxy class in the event that the - class is abstract - the error message is now - "No constructor defined - class is abstract" whereas if there are no - public constructors for any other reason and the class is not abstract, - the message remains - "No constructor defined". - [tcl] Similarly for tcl when using -itcl. - -2009-08-04: olly - [PHP] Fix generated code to work with PHP 5.3. - -2009-08-04: vmiklos - [PHP] Various mathematical functions (which would conflict - with the built-in PHP ones) are now automatically handled by - adding a 'c_' prefix. - -2009-08-03: wsfulton - [C#] The std::vector implementation is improved and now uses $typemap such - that the proxy class for T no longer has to be specified in some macros - for correct C# compilation; the following macros are deprecated, where - CSTYPE was the C# type for the C++ class CTYPE: - - SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE) - usage should be removed altogether - - SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE) - should be replaced with: - SWIG_STD_VECTOR_ENHANCED(CTYPE) - - Some more details in csharp/std_vector.i - - *** POTENTIAL INCOMPATIBILITY *** - -2009-07-31: olly - [Python] Fix indentation so that we give a useful error if the - module can't be loaded. Patch from Gaetan Lehmann in SF#2829853. - -2009-07-29: wsfulton - Add $typemap(method, typelist) special variable macro. This allows - the contents of a typemap to be inserted within another typemap. - Fully documented in Typemaps.html. - -2009-07-29: vmiklos - [PHP] Static member variables are now prefixed with the - class name. This allows static member variables with the - same name in different classes. - -2009-07-29: olly - [Python] Add missing locks to std::map wrappers. Patch from - Paul Hampson in SF#2813836. - -2009-07-29: olly - [PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi - Amano in SF#2826322. - -2009-07-29: olly - [PHP] Fix memory leak in PHP resource destructor for classes - without a destructor and non-class types. Patch from Hitoshi Amano - in SF#2825303. - -2009-07-28: olly - [PHP] Update warnings about clashes between identifiers and PHP - keywords and automatic renaming to work with the PHP5 class - wrappers. Fixes SF#1613679. - -2009-07-28: vmiklos - [PHP] If a member function is not public but it has a base - which is public, then now a warning is issued and the member - function will be public, as PHP requires this. - -2009-07-21: vmiklos - [PHP] Director support added. - -2009-07-15: olly - [Perl] Don't specify Perl prototype "()" for a constructor with a - different name to the class, as such constructors can still take - parameters. - -2009-07-12: xavier98 - [Octave] Add support for Octave 3.2 API - -2009-07-05: olly - [PHP] Update the list of PHP keywords - "cfunction" is no longer a - keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__", - and "__NAMESPACE__". - -2009-07-03: olly - [Tcl] To complement USE_TCL_STUBS, add support for USE_TK_STUBS - and SWIG_TCL_STUBS_VERSION. Document all three in the Tcl chapter - of the manual. Based on patch from SF#2810380 by Christian - Gollwitzer. - -2009-07-02: vmiklos - [PHP] Added factory.i for PHP, see the li_factory testcase - for more info on how to use it. - -2009-07-02: wsfulton - Fix -Wallkw option as reported by Solomon Gibbs. - -2009-07-02: wsfulton - Fix syntax error when a nested struct contains a comment containing a * followed - eventually by a /. Regression from 1.3.37, reported by Solomon Gibbs. - -2009-07-01: vmiklos - [PHP] Unknown properties are no longer ignored in proxy - classes. - -2009-07-01: vmiklos - [PHP] Fixed %newobject behaviour, previously any method - marked with %newobject was handled as a constructor. - -2009-06-30: olly - [Ruby] Undefine close and connect macros defined by Ruby API - headers as we don't need them and they can clash with C++ methods - being wrapped. Patch from Vit Ondruch in SF#2814430. - -2009-06-26: olly - [Ruby] Fix to handle FIXNUM values greater than MAXINT passed for a - double parameter. - -2009-06-24: wsfulton - Fix wrapping methods with default arguments and the compactdefaultargs feature - where a class is passed by value and is assigned a default value. The SwigValueWrapper - template workaround for a missing default constructor is no longer used as the code - generated does not call the default constructor. - -2009-06-16: wsfulton - [Java,C#] Fix enum marshalling when %ignore is used on one of the enum items. - Incorrect enum values were being passed to the C++ layer or compilation errors resulted. - -2009-06-02: talby - [Perl] Resolved reference.i overload support problem - identified by John Potowsky. - -2009-05-26: wsfulton - [C#] Improved std::map wrappers based on patch from Yuval Baror. The C# proxy - now implements System.Collections.Generic.IDictionary<>. - - These std:map wrappers have a non-backwards compatible overhaul to make them - like a .NET IDictionary. Some method names have changed as following: - set -> setitem (use this[] property now) - get -> getitem (use this[] property now) - has_key -> ContainsKey - del -> Remove - clear -> Clear - - The following macros used for std::map wrappers are deprecated and will no longer work: - specialize_std_map_on_key - specialize_std_map_on_value - specialize_std_map_on_both - - *** POTENTIAL INCOMPATIBILITY *** - -2009-05-20: vmiklos - [PHP] Add the 'thisown' member to classes. The usage of it - is the same as the Python thisown one: it's 1 by default and - you can set it to 0 if you want to prevent freeing it. (For - example to prevent a double free.) - -2009-05-14: bhy - [Python] Fix the wrong pointer value returned by SwigPyObject_repr(). - -2009-05-13: mutandiz (Mikel Bancroft) - [allegrocl] Minor tweak when wrapping in -nocwrap mode. - -2009-05-11: wsfulton - [C#] Improved std::vector wrappers on the C# proxy side from Yuval Baror. These - implement IList<> instead of IEnumerable<> where possible. - -2009-04-29: wsfulton - [Java, C#] Add the 'notderived' attribute to the javabase and csbase typemaps. - When this attribute is set, the typemap will not apply to classes that are derived - from a C++ base class, eg - %typemap(csbase, notderived="1") SWIGTYPE "CommonBase" - -2009-04-29: olly - [Python] Don't attempt to acquire the GIL in situations where we - know that it will already be locked. This avoids some dead-locks - with mod_python (due to mod_python bugs which are apparently - unlikely to ever be fixed), and results in smaller wrappers which - run a little faster (in tests with Xapian on x86-64 Ubuntu 9.04, - the stripped wrapper library was 11% smaller and ran 2.7% faster). - -2009-04-21: wsfulton - [C#] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation. - -2009-04-09: wsfulton - Fix #2746858 - C macro expression using floating point numbers - -2009-03-30: olly - [PHP] The default out typemap for char[ANY] now returns the string up to a - zero byte, or the end of the array if there is no zero byte. This - is the same as Python does, and seems more generally useful than - the previous behaviour of returning the whole contents of the array - including any zero bytes. If you want the old behaviour, you can provide - your own typemap to do this: - - %typemap(out) char [ANY] - %{ - RETVAL_STRINGL($1, $1_dim0, 1); - %} diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index e39633e38..b98661c0d 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

        SWIG-1.3 Development Documentation

        -Last update : SWIG-1.3.40 (18 August 2009) +Last update : SWIG-1.3.41 (in progress)

        Sections

        diff --git a/README b/README index dbf438f51..4af2da56f 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.40 (18 August 2009) +Version: 1.3.41 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, diff --git a/configure.in b/configure.in index 4edc8e1ae..96c3d18b0 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. dnl The macros which aren't shipped with the autotools are stored in the dnl Tools/config directory in .m4 files. -AC_INIT([swig],[1.3.40],[http://www.swig.org]) +AC_INIT([swig],[1.3.41],[http://www.swig.org]) AC_PREREQ(2.58) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) AC_CONFIG_AUX_DIR([Tools/config]) From a90d30b4fda91ce28cb0d5b5afe3fb54382a4621 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 19 Aug 2009 00:14:15 +0000 Subject: [PATCH 179/352] mention CHANGES.current in README file git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11648 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- README | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README b/README index 4af2da56f..2101925fe 100644 --- a/README +++ b/README @@ -64,7 +64,7 @@ Major contributors include: Past contributors include: James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran Kovuk, Oleg Tolmatcev, Tal Shalif, Lluis Padro, Chris Seatory, Igor Bely, Robin Dunn - (See CHANGES for a more complete list). + (See CHANGES and CHANGES.current for a more complete list). Portions also copyrighted by companies/corporations; Network Applied Communication Laboratory, Inc @@ -376,8 +376,10 @@ well advised to read this. Release Notes ============= -Please see the CHANGES files for a detailed list of bug fixes and -new features. A summary of the changes is included in this README file. +Please see the CHANGES.current file for a detailed list of bug fixes and +new features for the current release. The CHANGES file contains bug fixes +and new features for older versions. A summary of the changes is included +in this README file. Windows Installation ==================== From 9584c00eaa7c3c16009e4f2173aa079d1f2a97fa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 19 Aug 2009 00:23:38 +0000 Subject: [PATCH 180/352] Fix release date for 1.3.40 for last commit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11649 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 8360207c2..509484e2f 100644 --- a/CHANGES +++ b/CHANGES @@ -2,7 +2,7 @@ SWIG (Simplified Wrapper and Interface Generator) See CHANGES.current for current version. -Version 1.3.40 (in progress) +Version 1.3.40 (18 August 2009) =============================== 2009-08-17: olly From 2c6fedd1d2df236fe4f4eebb5b16b10a73aeb41e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Aug 2009 22:53:17 +0000 Subject: [PATCH 181/352] fix make distclean git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11657 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.in b/Makefile.in index 19d37dc3b..111d7d878 100644 --- a/Makefile.in +++ b/Makefile.in @@ -388,7 +388,7 @@ maintainer-clean: clean-libfiles DISTCLEAN-DEAD = config.status config.log config.cache swig.spec Makefile mkmf.log libtool -distclean: distclean-objects clean-examples clean-gifplot distclean-test-suite clean-docs distclean-dead distclean-ccache +distclean: clean-docs distclean-objects clean-examples clean-gifplot distclean-test-suite distclean-dead distclean-ccache distclean-objects: distclean-source From 9d6e826bd8d76e43a9d00cbd446c7e3949514c82 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Aug 2009 23:21:07 +0000 Subject: [PATCH 182/352] Test std::map in all languages git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11658 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + Examples/test-suite/octave/Makefile.in | 1 - Examples/test-suite/python/Makefile.in | 1 - Examples/test-suite/ruby/Makefile.in | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 492378b16..4c469ded0 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -409,6 +409,7 @@ CPP_STD_TEST_CASES += \ li_std_combinations \ li_std_deque \ li_std_except \ + li_std_map \ li_std_pair \ li_std_string \ li_std_vector \ diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index 70de84adc..a9a7649ec 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -17,7 +17,6 @@ CPP_TEST_CASES += \ CPP_TEST_BROKEN += \ implicittest \ li_implicit \ - li_std_map \ li_std_set \ li_std_stream diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 274d53f1d..4938ddc27 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -49,7 +49,6 @@ CPP_TEST_CASES += \ li_implicit \ li_std_vectora \ li_std_vector_extra \ - li_std_map \ li_std_multimap \ li_std_pair_extra \ li_std_set \ diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index dc8751da1..27996616e 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -14,7 +14,6 @@ CPP_TEST_CASES = \ li_cstring \ li_factory \ li_std_functors \ - li_std_map \ li_std_multimap \ li_std_pair_lang_object \ li_std_queue \ From b56cd0b0f671b3c367abe2216ac53c82b933d3ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 20 Aug 2009 23:55:25 +0000 Subject: [PATCH 183/352] remove unused directory creation git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11660 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 1 - 1 file changed, 1 deletion(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index 29cf8db1b..2f4decfff 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -37,7 +37,6 @@ $(PACKAGE_NAME).1: ccache.yo -yodl2man -o $(PACKAGE_NAME).1 ccache.yo web/ccache-man.html: ccache.yo - mkdir -p man yodl2html -o web/ccache-man.html ccache.yo install: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1 From 1be8bd5d8eee68bfe2806cc0efbbbaf86409af6f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 21 Aug 2009 00:00:23 +0000 Subject: [PATCH 184/352] tidy up distclean git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11662 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index 2f4decfff..f885e72ae 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -63,7 +63,7 @@ test: test.sh check: test distclean: clean distclean-docs - /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status configure config.h + /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status configure config.h.in ccache_swig_config.h # FIXME: To fix this, test.sh needs to be able to take ccache from the # installed prefix, not from the source dir. From 3932d02a2a74984ac016692cd34efbf7952060ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 21 Aug 2009 00:25:11 +0000 Subject: [PATCH 185/352] fix SWIG naming convention git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11663 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Allegrocl.html | 4 ++-- Doc/Manual/CSharp.html | 2 +- Doc/Manual/Contents.html | 2 +- Doc/Manual/Guile.html | 4 ++-- Doc/Manual/Perl5.html | 2 +- Doc/Manual/Php.html | 2 +- Doc/Manual/Python.html | 6 +++--- Doc/Manual/Ruby.html | 4 ++-- Doc/Manual/SWIGPlus.html | 2 +- Examples/java/pointer/index.html | 2 +- Examples/perl5/pointer/index.html | 2 +- Examples/python/pointer/index.html | 2 +- Examples/ruby/pointer/index.html | 2 +- Examples/tcl/pointer/index.html | 2 +- Lib/lua/luarun.swg | 2 +- Lib/php/director.swg | 4 ++-- Lib/python/director.swg | 10 +++++----- Lib/ruby/director.swg | 10 +++++----- Lib/tcl/typemaps.i | 4 ++-- Lib/typemaps/fragments.swg | 6 +++--- Lib/typemaps/swigmacros.swg | 6 +++--- Source/Modules/modula3.cxx | 2 +- Source/Preprocessor/cpp.c | 4 ++-- 23 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index cc950db7c..cf70f6c27 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -14,7 +14,7 @@
        • Basics @@ -138,7 +138,7 @@ to it.

          17.1 Basics

          -

          17.1.1 Running Swig

          +

          17.1.1 Running SWIG

          diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index f747fc213..f092d188a 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -55,7 +55,7 @@ The PInvoke interface has been chosen over Microsoft's Managed C++ interface as PInvoke is part of the ECMA/ISO C# specification. It is also better suited for robust production environments due to the Managed C++ flaw called the Mixed DLL Loading Problem. -Swig C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using +SWIG C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using Mono and Portable.NET.

          diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 0e7ebf464..85b1ab5f5 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -537,7 +537,7 @@
          • Basics diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index cf7e8da2c..61b5ba7d6 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -814,7 +814,7 @@ Produces the following code at the top of the generated GOOPS guile-module Module-primitive.scm (with primitive replaced with whatever is given with the -primsuffix argument. The code to load the .so library should be located in the %scheme directive, which will then be added to the scmstub file. -Swig will automatically generate the line (use-modules (Package Module-primitive)) +SWIG will automatically generate the line (use-modules (Package Module-primitive)) into the GOOPS guile-module. So if Module-primitive.scm is on the autoload path for guile, the %goops directive can be empty. Otherwise, the %goops directive should contain whatever code is needed to load the Module-primitive.scm file into guile.

            @@ -848,7 +848,7 @@ Produces the following code at the top of the generated GOOPS guile-module
          • Module Linkage: This is very similar to passive linkage with a scmstub file. -Swig will also automatically generate the line (use-modules +SWIG will also automatically generate the line (use-modules (Package Module-primitive)) into the GOOPS guile-module. Again the %goops directive should contain whatever code is needed to get that module loaded into guile.

            diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 8f74bd1de..40500dc5a 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -112,7 +112,7 @@ options are found near the end of the chapter.

            -To build a Perl5 module, run Swig using the -perl option as +To build a Perl5 module, run SWIG using the -perl option as follows :

            diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index de745e135..b9dcb83c5 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -101,7 +101,7 @@ also contain PHP5 class wrappers.

            -Swig can generate PHP extensions from C++ libraries as well when +SWIG can generate PHP extensions from C++ libraries as well when given the -c++ option. The support for C++ is discussed in more detail in section 27.2.6.

            diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 8b359bda9..a739543df 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -1137,7 +1137,7 @@ simply represented as opaque values using an especial python container object:
             >>> print f
            -<Swig Object at _08a71808_p_FILE>
            +<Swig Object of type 'FILE *' at 0xb7d6f470>
             

            @@ -1147,7 +1147,7 @@ dereference the pointer from Python. Of course, that isn't much of a concern in

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

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

            diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 98fa315d0..643a6daec 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -7097,7 +7097,7 @@ being created. with Ruby objects. The following functions may prove to be useful. (These functions plus many more can be found in Programming Ruby, by David Thomas and Andrew Hunt.) 

            -

            In addition, we list equivalent functions that Swig defines, which +

            In addition, we list equivalent functions that SWIG defines, which provide a language neutral conversion (these functions are defined for each swig language supported).  If you are trying to create a swig file that will work under multiple languages, it is recommended you @@ -7123,7 +7123,7 @@ across multiple languages.

            RUBY - Swig + SWIG diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index ef7487ff8..f3befa54b 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -3471,7 +3471,7 @@ instead:

            In this case, the default and conversion constructors have the same -name. Hence, Swig will overload them and define an unique visible +name. Hence, SWIG will overload them and define an unique visible constructor, that will dispatch the proper call depending on the argument type.

            diff --git a/Examples/java/pointer/index.html b/Examples/java/pointer/index.html index e20fe3328..5c93d4d58 100644 --- a/Examples/java/pointer/index.html +++ b/Examples/java/pointer/index.html @@ -143,7 +143,7 @@ extraction. diff --git a/Examples/perl5/pointer/index.html b/Examples/perl5/pointer/index.html index 6f9fd397d..94467bc36 100644 --- a/Examples/perl5/pointer/index.html +++ b/Examples/perl5/pointer/index.html @@ -144,7 +144,7 @@ extraction. diff --git a/Examples/python/pointer/index.html b/Examples/python/pointer/index.html index ceef30566..b99c8fe4c 100644 --- a/Examples/python/pointer/index.html +++ b/Examples/python/pointer/index.html @@ -144,7 +144,7 @@ extraction. diff --git a/Examples/ruby/pointer/index.html b/Examples/ruby/pointer/index.html index 2b9c40b35..c9d5b9c32 100644 --- a/Examples/ruby/pointer/index.html +++ b/Examples/ruby/pointer/index.html @@ -144,7 +144,7 @@ extraction. diff --git a/Examples/tcl/pointer/index.html b/Examples/tcl/pointer/index.html index 874088a72..407380240 100644 --- a/Examples/tcl/pointer/index.html +++ b/Examples/tcl/pointer/index.html @@ -144,7 +144,7 @@ extraction. diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 32e1b1617..9bb45d577 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -79,7 +79,7 @@ typedef struct { /* this is the struct for wrapping arbitary packed binary data (currently it is only used for member function pointers) the data ordering is similar to swig_lua_userdata, but it is currently not possible -to tell the two structures apart within Swig, other than by looking at the type +to tell the two structures apart within SWIG, other than by looking at the type */ typedef struct { swig_type_info *type; diff --git a/Lib/php/director.swg b/Lib/php/director.swg index 6a9d4df3c..b28f6dbd9 100644 --- a/Lib/php/director.swg +++ b/Lib/php/director.swg @@ -168,7 +168,7 @@ namespace Swig { { public: DirectorPureVirtualException(const char* msg) - : DirectorException(E_ERROR, "Swig director pure virtual method called", msg) + : DirectorException(E_ERROR, "SWIG director pure virtual method called", msg) { } @@ -182,7 +182,7 @@ namespace Swig { { public: DirectorMethodException(const char* msg = "") - : DirectorException(E_ERROR, "Swig director method error", msg) + : DirectorException(E_ERROR, "SWIG director method error", msg) { } diff --git a/Lib/python/director.swg b/Lib/python/director.swg index ba9144539..f3855babe 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -237,7 +237,7 @@ namespace Swig { try { throw; } catch (DirectorException& e) { - std::cerr << "Swig Director exception caught:" << std::endl + std::cerr << "SWIG Director exception caught:" << std::endl << e.getMessage() << std::endl; } catch (std::exception& e) { std::cerr << "std::exception caught: "<< e.what() << std::endl; @@ -276,12 +276,12 @@ namespace Swig { class DirectorTypeMismatchException : public Swig::DirectorException { public: DirectorTypeMismatchException(PyObject *error, const char* msg="") - : Swig::DirectorException(error, "Swig director type mismatch", msg) + : Swig::DirectorException(error, "SWIG director type mismatch", msg) { } DirectorTypeMismatchException(const char* msg="") - : Swig::DirectorException(PyExc_TypeError, "Swig director type mismatch", msg) + : Swig::DirectorException(PyExc_TypeError, "SWIG director type mismatch", msg) { } @@ -300,7 +300,7 @@ namespace Swig { class DirectorMethodException : public Swig::DirectorException { public: DirectorMethodException(const char* msg = "") - : DirectorException(PyExc_RuntimeError, "Swig director method error.", msg) + : DirectorException(PyExc_RuntimeError, "SWIG director method error.", msg) { } @@ -315,7 +315,7 @@ namespace Swig { { public: DirectorPureVirtualException(const char* msg = "") - : DirectorException(PyExc_RuntimeError, "Swig director pure virtual method called", msg) + : DirectorException(PyExc_RuntimeError, "SWIG director pure virtual method called", msg) { } diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg index 9a6371ad9..76969cadc 100644 --- a/Lib/ruby/director.swg +++ b/Lib/ruby/director.swg @@ -176,7 +176,7 @@ namespace Swig { try { throw; } catch (DirectorException& e) { - std::cerr << "Swig Director exception caught:" << std::endl + std::cerr << "SWIG Director exception caught:" << std::endl << e.getMessage() << std::endl; } catch (std::exception& e) { std::cerr << "std::exception caught: "<< e.what() << std::endl; @@ -212,12 +212,12 @@ namespace Swig { class DirectorTypeMismatchException : public Swig::DirectorException { public: DirectorTypeMismatchException(VALUE error, const char *msg="") - : Swig::DirectorException(error, "Swig director type mismatch", msg) + : Swig::DirectorException(error, "SWIG director type mismatch", msg) { } DirectorTypeMismatchException(const char *msg="") - : Swig::DirectorException(rb_eTypeError, "Swig director type mismatch", msg) + : Swig::DirectorException(rb_eTypeError, "SWIG director type mismatch", msg) { } @@ -238,7 +238,7 @@ namespace Swig { } DirectorMethodException(const char* msg = "") - : Swig::DirectorException(rb_eRuntimeError, "Swig director method error.", msg) { + : Swig::DirectorException(rb_eRuntimeError, "SWIG director method error.", msg) { } static void raise(VALUE error) @@ -252,7 +252,7 @@ namespace Swig { { public: DirectorPureVirtualException(const char* msg = "") - : DirectorException(rb_eRuntimeError, "Swig director pure virtual method called", msg) + : DirectorException(rb_eRuntimeError, "SWIG director pure virtual method called", msg) { } diff --git a/Lib/tcl/typemaps.i b/Lib/tcl/typemaps.i index 7c9e04a8b..2a8f1064a 100644 --- a/Lib/tcl/typemaps.i +++ b/Lib/tcl/typemaps.i @@ -4,8 +4,8 @@ * * typemaps.i * - * Swig typemap library for Tcl8. This file contains various sorts - * of typemaps for modifying Swig's code generation. + * SWIG typemap library for Tcl8. This file contains various sorts + * of typemaps for modifying SWIG's code generation. * ----------------------------------------------------------------------------- */ #if !defined(SWIG_USE_OLD_TYPEMAPS) diff --git a/Lib/typemaps/fragments.swg b/Lib/typemaps/fragments.swg index 6d3e20223..ef6a346cc 100644 --- a/Lib/typemaps/fragments.swg +++ b/Lib/typemaps/fragments.swg @@ -444,15 +444,15 @@ SWIG_AsVal_dec(Type)(SWIG_Object obj, Type *val) %define %ensure_fragment(Fragment) %fragment(`Fragment`,"header") { -%#error "Swig language implementation must provide the Fragment fragment" +%#error "SWIG language implementation must provide the Fragment fragment" } %enddef %define %ensure_type_fragments(Type) %fragment(SWIG_From_frag(Type),"header") { -%#error "Swig language implementation must provide a SWIG_From_frag(Type) fragment" +%#error "SWIG language implementation must provide a SWIG_From_frag(Type) fragment" } %fragment(SWIG_AsVal_frag(Type),"header") { -%#error "Swig language implementation must provide a SWIG_AsVal_frag(Type) fragment" +%#error "SWIG language implementation must provide a SWIG_AsVal_frag(Type) fragment" } %enddef diff --git a/Lib/typemaps/swigmacros.swg b/Lib/typemaps/swigmacros.swg index 928f4ec0c..e95e7af92 100644 --- a/Lib/typemaps/swigmacros.swg +++ b/Lib/typemaps/swigmacros.swg @@ -20,7 +20,7 @@ Casting Operations: ------------------- - Swig provides the following casting macros, which implement the + SWIG provides the following casting macros, which implement the corresponding C++ casting operations: %const_cast(a, Type) const_cast(a) @@ -173,7 +173,7 @@ nocppval #endif /* __cplusplus */ /* ----------------------------------------------------------------------------- - * Swig names and mangling + * SWIG names and mangling * ----------------------------------------------------------------------------- */ #define %mangle(Type...) #@Type @@ -210,7 +210,7 @@ nocppval %define %formacro_2(macro,...)%_formacro_2(macro, __VA_ARGS__, __fordone__)%enddef /* ----------------------------------------------------------------------------- - * Swig flags + * SWIG flags * ----------------------------------------------------------------------------- */ /* diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index b14dddd22..7440d906a 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -81,7 +81,7 @@ char cvsroot_modula3_cxx[] = "$Id$"; that assign special purposes to the array types. - Can one interpret $n_basetype as the identifier matched with SWIGTYPE ? - Swig's odds: + SWIG's odds: - arguments of type (Node *) for SWIG functions should be most often better (const Node *): Swig_symbol_qualified, Getattr, nodeType, parentNode diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 81646171a..7958b4e09 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -1648,7 +1648,7 @@ String *Preprocessor_parse(String *s) { state = 0; break; - /* Swig directives */ + /* SWIG directives */ case 100: /* %{,%} block */ if (c == '{') { @@ -1713,7 +1713,7 @@ String *Preprocessor_parse(String *s) { case 110: if (!isidchar(c)) { Ungetc(c, s); - /* Look for common Swig directives */ + /* Look for common SWIG directives */ if (Equal(decl, kpp_dinclude) || Equal(decl, kpp_dimport) || Equal(decl, kpp_dextern)) { /* Got some kind of file inclusion directive */ if (allow) { From 415d2b6fe923b30ab526d6ed3a69cf78290643b7 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 29 Aug 2009 06:53:25 +0000 Subject: [PATCH 186/352] [Perl] Remove bogus assertion (patch from David Fletcher). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11671 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 ++ Lib/perl5/perlrun.swg | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 99cade363..8414f06c9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,3 +1,5 @@ Version 1.3.41 (in progress) ============================ +2009-08-29: olly + [Perl] Remove bogus assertion (patch from David Fletcher). diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index be788f540..94bc5e48c 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -293,7 +293,6 @@ SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_ int newmemory = 0; *ptr = SWIG_TypeCast(tc,voidptr,&newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { - assert(own); if (own) *own = *own | SWIG_CAST_NEW_MEMORY; } From 6edbe9cdc2b59d327d28f983be1724dc87a8791a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 Aug 2009 10:09:01 +0000 Subject: [PATCH 187/352] extra white space helps disambiguate the expression which some compilers/tools complain about - patch from David Fletcher git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11672 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/perl5/perlrun.swg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index 94bc5e48c..983633355 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -310,7 +310,7 @@ SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_ */ SV *obj = sv; HV *stash = SvSTASH(SvRV(obj)); - GV *gv = *(GV**) hv_fetch(stash, "OWNER", 5, TRUE); + GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE); if (isGV(gv)) { HV *hv = GvHVn(gv); /* @@ -341,7 +341,7 @@ SWIG_Perl_MakePtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void *ptr, swig_type_info *t, i stash=SvSTASH(SvRV(obj)); if (flags & SWIG_POINTER_OWN) { HV *hv; - GV *gv=*(GV**)hv_fetch(stash, "OWNER", 5, TRUE); + GV *gv = *(GV**)hv_fetch(stash, "OWNER", 5, TRUE); if (!isGV(gv)) gv_init(gv, stash, "OWNER", 5, FALSE); hv=GvHVn(gv); From 7908bb2dc3e21bb3d27b24cfdee2683d3fcd3deb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 29 Aug 2009 10:41:06 +0000 Subject: [PATCH 188/352] Add information about the SWIG test-suite git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11673 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 8 +- Doc/Manual/Extending.html | 239 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 237 insertions(+), 10 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 85b1ab5f5..d6feb934f 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1581,7 +1581,7 @@
          • Writing a Language Module
            • Execution model -
            • Starting out +
            • Starting out
            • Command line options
            • Configuration and preprocessing
            • Entry point to code generation @@ -1590,7 +1590,11 @@
            • Configuration files
            • Runtime support
            • Standard library files -
            • Examples and test cases +
            • User examples +
            • Test driven development and the test-suite +
            • Documentation
            • Prerequisites for adding a new language module to the SWIG distribution
            • Coding style guidelines diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 0ebaeaa04..c56647450 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -48,7 +48,7 @@
            • Writing a Language Module
              • Execution model -
              • Starting out +
              • Starting out
              • Command line options
              • Configuration and preprocessing
              • Entry point to code generation @@ -57,7 +57,11 @@
              • Configuration files
              • Runtime support
              • Standard library files -
              • Examples and test cases +
              • User examples +
              • Test driven development and the test-suite +
              • Documentation
              • Prerequisites for adding a new language module to the SWIG distribution
              • Coding style guidelines @@ -2471,7 +2475,7 @@ the parsing of command line options, all aspects of code generation are controll different methods of the Language that must be defined by your module.

                -

                35.10.2 Starting out

                +

                35.10.2 Starting out

                @@ -3053,7 +3057,7 @@ but without the typemaps, there is still work to do.

                -At the time of this writing, SWIG supports nearly a dozen languages, +At the time of this writing, SWIG supports nearly twenty languages, which means that for continued sanity in maintaining the configuration files, the language modules need to follow some conventions. These are outlined here along with the admission that, yes it is ok to violate @@ -3225,7 +3229,7 @@ The following are the minimum that are usually supported: Please copy these and modify for any new language.

                -

                35.10.11 Examples and test cases

                +

                35.10.11 User examples

                @@ -3254,7 +3258,226 @@ during this process, see the section on configuration files.

                -

                35.10.12 Documentation

                +

                35.10.12 Test driven development and the test-suite

                + + +

                +A test driven development approach is central to the improvement and development of SWIG. +Most modifications to SWIG are accompanied by additional regression tests and checking all +tests to ensure that no regressions have been introduced. +

                + +

                +The regression testing is carried out by the SWIG test-suite. +The test-suite consists of numerous testcase interface files in the Examples/test-suite directory +as well as target language specific runtime tests in the Examples/test-suite/[lang] directory. +When a testcase is run, it will execute the following steps for each testcase: +

                + +
                  +
                1. Execute SWIG passing it the testcase interface file.
                2. +
                3. Compile the resulting generated C/C++ code with either the C or C++ compiler into object files.
                4. +
                5. Link the object files into a dynamic library (dll/shared object).
                6. +
                7. Compile any generated and any runtime test target language code with the target language compiler, if the target language supports compilation. This step thus does not apply to the interpreted languages.
                8. +
                9. Execute a runtime test if one exists.
                10. +
                + +

                +For example, the ret_by_value testcase consists of two components. +The first component is the Examples/test-suite/ret_by_value.i interface file. +The name of the SWIG module must always be the name of the testcase, so the ret_by_value.i interface file thus begins with: +

                + +
                +
                +%module ret_by_value
                +
                +
                + +

                +The testcase code will then follow the module declaration, +usually within a %inline %{ ... %} section for the majority of the tests. +

                + +

                +The second component is the optional runtime tests. +Any runtime tests are named using the following convention: [testcase]_runme.[ext], +where [testcase] is the testcase name and [ext] is the normal extension for the target language file. +In this case, the Java and Python target languages implement a runtime test, so their files are respectively, +Examples/test-suite/java/ret_by_value_runme.java and +Examples/test-suite/python/ret_by_value_runme.py. +

                + +

                +The goal of the test-suite is to test as much as possible in a silent manner. +This way any SWIG or compiler errors or warnings are easily visible. +Should there be any warnings, changes must be made to either fix them (preferably) or suppress them. +Compilation or runtime errors result in a testcase failure and will be immediately visible. +It is therefore essential that the runtime tests are written in a manner that displays nothing to stdout/stderr on success +but error/exception out with an error message on stderr on failure. +

                + +

                35.10.12.1 Running the test-suite

                + + +

                +In order for the test-suite to work for a particular target language, the language must be correctly detected +and configured during the configure stage so that the correct Makefiles are generated. +Most development occurs on Linux, so usually it is a matter of installing the development packages for the target language +and simply configuring as outlined earlier. +

                + +

                +If when running the test-suite commands that follow, you get a message that the test was skipped, it indicates that the +configure stage is missing information in order to compile and run everything for that language. +

                + +

                +The test-suite can be run in a number of ways. +The first group of commands are for running multiple testcases in one run and should be executed in the top level directory. +To run the entire test-suite (can take a long time): +

                + +
                +make -k check-test-suite
                +
                + +

                +To run the test-suite just for target language [lang], replace [lang] with one of csharp, java, perl5, python, ruby, tcl etc: +

                + +
                +make check-[lang]-test-suite
                +
                + +

                +Note that if a runtime test is available, a message "(with run test)" is displayed when run. For example: +

                + +
                +$ make check-python-test-suite
                +checking python test-suite
                +checking testcase argcargvtest (with run test) under python
                +checking testcase python_autodoc under python
                +checking testcase python_append (with run test) under python
                +checking testcase callback (with run test) under python
                +
                + +

                +The files generated on a previous run can be deleted using the clean targets, either the whole test-suite or for a particular language: +

                + +
                +make clean-test-suite
                +make clean-[lang]-test-suite
                +
                + +

                +The test-suite can be run in a partialcheck mode where just SWIG is executed, that is, the compile, +link and running of the testcases is not performed. +Note that the partialcheck does not require the target language to be correctly configured and detected and unlike the other test-suite make targets, is never skipped. Once again, either all the languages can be executed or just a chosen language: +

                + +
                +make partialcheck-test-suite
                +make partialcheck-[lang]-test-suite
                +
                + +

                +If your computer has more than one CPU, you are strongly advised to use parallel make to speed up the execution speed. +This can be done with any of the make targets that execute more than one testcase. +For example, a dual core processor can efficiently use 2 parallel jobs: +

                + +
                +make -j2 check-test-suite
                +make -j2 check-python-test-suite
                +make -j2 partialcheck-java-test-suite
                +
                + +

                +The second group of commands are for running individual testcases and should be executed in the appropriate +target language directory, Examples/test-suite/[lang]. +Testcases can contain either C or C++ code and when one is written, a decision must be made as to which of these input +languages is to be used. +Replace [testcase] in the commands below with the name of the testcase. +

                + +

                +For a C language testcase, add the testcase under the C_TEST_CASES list in Examples/test-suite/common.mk and +execute individually as: +

                +
                +make -s [testcase].ctest
                +
                + +

                +For a C++ language testcase, add the testcase under the CPP_TEST_CASES list in Examples/test-suite/common.mk and +execute individually as: +

                +
                +make -s [testcase].cpptest
                +
                + +

                +A third category of tests are C++ language testcases testing multiple modules (the %import directive). +These require more than one shared library (dll/shared object) to be built and so are separated out from the normal C++ testcases. +Add the testcase under the MULTI_CPP_TEST_CASES list in Examples/test-suite/common.mk and +execute individually as: +

                +
                +make -s [testcase].multicpptest
                +
                + +

                +To delete the generated files, execute: +

                +
                +make -s [testcase].clean
                +
                + +

                +If you would like to see the exact commands being executed, drop the -s option: +

                +
                +make [testcase].ctest
                +make [testcase].cpptest
                +make [testcase].multicpptest
                +
                + +

                +Some real examples of each: +

                +
                +make -s ret_by_value.clean
                +make -s ret_by_value.ctest
                +make -s bools.cpptest
                +make -s imports.multicpptest
                +
                + +

                +Advanced usage of the test-suite facilitates running tools on some of the five stages. +The make variables SWIGTOOL and RUNTOOL are used to specify a tool to respectively, invoke SWIG +and the execution of the runtime test. +You are advised to view the Examples/test-suite/common.mk file for details but for a short summary, +the classic usage is to use Valgrind for memory checking. +For example, checking for memory leaks when running the runtime test in the target language interpreter: +

                + +
                +make ret_by_value.ctest RUNTOOL="valgrind --leak-check=full"
                +
                + +

                +This will probably make more sense if you look at the output of the above as it will show the exact commands being executed. +SWIG can be analyzed for bad memory accesses using: +

                + +
                +make ret_by_value.ctest SWIGTOOL="valgrind --tool=memcheck --trace-children=yes"
                +
                + +

                35.10.13 Documentation

                @@ -3286,7 +3509,7 @@ Some topics that you'll want to be sure to address include: if available.

              -

              35.10.13 Prerequisites for adding a new language module to the SWIG distribution

              +

              35.10.14 Prerequisites for adding a new language module to the SWIG distribution

              @@ -3343,7 +3566,7 @@ should be added should there be an area not already covered by the existing tests.

              -

              35.10.14 Coding style guidelines

              +

              35.10.15 Coding style guidelines

              From 968eb8287a0cb0c622291653d6b495d79c92e207 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 1 Sep 2009 17:30:17 +0000 Subject: [PATCH 189/352] correction to SWIGTOOL usage git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11675 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 4c469ded0..f98067c5d 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -28,12 +28,14 @@ # 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 +# for invoking tools for the runtime tests and target language # compiler (eg javac) respectively. For example, valgrind can be used # for memory checking of the runtime tests using: -# make RUNTOOL="valgrind --leak-check-full" +# make RUNTOOL="valgrind --leak-check=full" # and valgrind can be used when invoking SWIG using: -# make SWIGTOOL="valgrind --tool=memcheck" +# make SWIGTOOL="valgrind --tool=memcheck --trace-children=yes" +# Note: trace-children needed because of preinst-swig shell wrapper +# to the swig executable. # # The variables below can be overridden after including this makefile ####################################################################### From d841f7a66c465a43aa3f849c5f4d75da89b2971e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 2 Sep 2009 20:49:55 +0000 Subject: [PATCH 190/352] fix overloading of jboolean with other JNI types at the c++ level for some platforms (64bit Linux) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11676 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/java/java_jnitypes_runme.java | 2 +- Examples/test-suite/java_jnitypes.i | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/java/java_jnitypes_runme.java b/Examples/test-suite/java/java_jnitypes_runme.java index 40395cef1..3e9d9e4c5 100644 --- a/Examples/test-suite/java/java_jnitypes_runme.java +++ b/Examples/test-suite/java/java_jnitypes_runme.java @@ -28,7 +28,7 @@ public class java_jnitypes_runme { double doubleArray[] = new double[] {10.0, 20.0}; Test objectArray[] = new Test[] {new Test(), test}; - if (java_jnitypes.jnifunc(true) != true) testFailed("jboolean"); + if (java_jnitypes.jnifunc_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"); diff --git a/Examples/test-suite/java_jnitypes.i b/Examples/test-suite/java_jnitypes.i index bc405793d..90970d1b2 100644 --- a/Examples/test-suite/java_jnitypes.i +++ b/Examples/test-suite/java_jnitypes.i @@ -5,7 +5,7 @@ %inline %{ -jboolean jnifunc(jboolean in) { return in; } +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; } From 7c6aca2ebc2c55cb9c7e25d8201e5b4bdb0907b2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 2 Sep 2009 22:33:04 +0000 Subject: [PATCH 191/352] true and false supported in constant expressions (C++ only). && || == != < > <= >= operators now return type bool (C++ only) and type int for C as per C/C++ standards. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11677 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 17 ++++ Examples/test-suite/common.mk | 2 + .../csharp/preproc_constants_c_runme.cs | 68 +++++++++++++++ .../csharp/preproc_constants_runme.cs | 67 +++++++++++++++ Examples/test-suite/preproc_constants.i | 82 +++++++++++++++++++ Examples/test-suite/preproc_constants_c.i | 6 ++ Source/CParse/cscanner.c | 8 +- Source/CParse/parser.y | 19 +++-- Source/Swig/scanner.c | 21 +++-- Source/Swig/swigscan.h | 1 + 10 files changed, 276 insertions(+), 15 deletions(-) create mode 100644 Examples/test-suite/csharp/preproc_constants_c_runme.cs create mode 100644 Examples/test-suite/csharp/preproc_constants_runme.cs create mode 100644 Examples/test-suite/preproc_constants.i create mode 100644 Examples/test-suite/preproc_constants_c.i diff --git a/CHANGES.current b/CHANGES.current index 8414f06c9..26f1434e1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,22 @@ Version 1.3.41 (in progress) ============================ +2009-09-02: wsfulton + The following operators in constant expressions now result in type bool for C++ + wrappers and remain as type int for C wrappers, as per each standard: + + && || == != < > <= >= (Actually the last 4 are still broken). For example: + + #define A 10 + #define B 10 + #define A_EQ_B A == B // now wrapped as type bool for C++ + #define A_AND_B A && B // now wrapped as type bool for C++ + +2009-09-02: wsfulton + Fix #2845746. true and false are now recognised keywords (only when wrapping C++). + Constants such as the following are now wrapped (as type bool): + #define FOO true + #define BAR FOO && false + 2009-08-29: olly [Perl] Remove bogus assertion (patch from David Fletcher). diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index f98067c5d..4bbf74525 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -257,6 +257,7 @@ CPP_TEST_CASES += \ overload_template \ overload_template_fast \ pointer_reference \ + preproc_constants \ primitive_ref \ private_assign \ protected_rename \ @@ -456,6 +457,7 @@ C_TEST_CASES += \ overload_extend \ overload_extendc \ preproc \ + preproc_constants_c \ ret_by_value \ simple_array \ sizeof_pointer \ diff --git a/Examples/test-suite/csharp/preproc_constants_c_runme.cs b/Examples/test-suite/csharp/preproc_constants_c_runme.cs new file mode 100644 index 000000000..71cf697f7 --- /dev/null +++ b/Examples/test-suite/csharp/preproc_constants_c_runme.cs @@ -0,0 +1,68 @@ +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_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/Examples/test-suite/csharp/preproc_constants_runme.cs b/Examples/test-suite/csharp/preproc_constants_runme.cs new file mode 100644 index 000000000..b2c6c62ae --- /dev/null +++ b/Examples/test-suite/csharp/preproc_constants_runme.cs @@ -0,0 +1,67 @@ +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_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/Examples/test-suite/preproc_constants.i b/Examples/test-suite/preproc_constants.i new file mode 100644 index 000000000..b759d8a75 --- /dev/null +++ b/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_LGE 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/Examples/test-suite/preproc_constants_c.i b/Examples/test-suite/preproc_constants_c.i new file mode 100644 index 000000000..e27d1f508 --- /dev/null +++ b/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/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 8734c7d0e..b5c485f5d 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -257,7 +257,7 @@ void skip_decl(void) { * Lexical scanner. * ------------------------------------------------------------------------- */ -int yylook(void) { +static int yylook(void) { int tok = 0; @@ -410,6 +410,9 @@ int yylook(void) { case SWIG_TOKEN_FLOAT: return NUM_FLOAT; + case SWIG_TOKEN_BOOL: + return NUM_BOOL; + case SWIG_TOKEN_POUND: Scanner_skip_line(scan); yylval.id = Swig_copy_string(Char(Scanner_text(scan))); @@ -525,6 +528,7 @@ int yylex(void) { case NUM_UNSIGNED: case NUM_LONGLONG: case NUM_ULONGLONG: + case NUM_BOOL: if (l == NUM_INT) yylval.dtype.type = T_INT; if (l == NUM_FLOAT) @@ -539,6 +543,8 @@ int yylex(void) { yylval.dtype.type = T_LONGLONG; if (l == NUM_ULONGLONG) yylval.dtype.type = T_ULONGLONG; + if (l == NUM_BOOL) + yylval.dtype.type = T_BOOL; yylval.dtype.val = NewString(Scanner_text(scan)); yylval.dtype.bitfield = 0; yylval.dtype.throws = 0; diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 7c33e5459..88e6a2005 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1486,7 +1486,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %token STRING %token INCLUDE IMPORT INSERT %token CHARCONST -%token NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG +%token NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG NUM_BOOL %token TYPEDEF %token TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64 %token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD @@ -5547,6 +5547,7 @@ exprnum : NUM_INT { $$ = $1; } | NUM_ULONG { $$ = $1; } | NUM_LONGLONG { $$ = $1; } | NUM_ULONGLONG { $$ = $1; } + | NUM_BOOL { $$ = $1; } ; exprcompound : expr PLUS expr { @@ -5591,28 +5592,28 @@ exprcompound : expr PLUS expr { } | expr LAND expr { $$.val = NewStringf("%s&&%s",$1.val,$3.val); - $$.type = T_INT; + $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr LOR expr { $$.val = NewStringf("%s||%s",$1.val,$3.val); - $$.type = T_INT; + $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr EQUALTO expr { $$.val = NewStringf("%s==%s",$1.val,$3.val); - $$.type = T_INT; + $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr NOTEQUALTO expr { $$.val = NewStringf("%s!=%s",$1.val,$3.val); - $$.type = T_INT; + $$.type = cparse_cplusplus ? T_BOOL : T_INT; } /* Sadly this causes 2 reduce-reduce conflicts with templates. FIXME resolve these. | expr GREATERTHAN expr { $$.val = NewStringf("%s SWIG_LT %s", $1.val, $3.val); - $$.type = T_INT; + $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr LESSTHAN expr { $$.val = NewStringf("%s SWIG_GT %s", $1.val, $3.val); - $$.type = T_INT; + $$.type = cparse_cplusplus ? T_BOOL : T_INT; } */ | expr GREATERTHANOREQUALTO expr { @@ -5620,11 +5621,11 @@ exprcompound : expr PLUS expr { * loop somewhere in the type system. Just workaround for now * - SWIG_GE is defined in swiglabels.swg. */ $$.val = NewStringf("%s SWIG_GE %s", $1.val, $3.val); - $$.type = T_INT; + $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr LESSTHANOREQUALTO expr { $$.val = NewStringf("%s SWIG_LE %s", $1.val, $3.val); - $$.type = T_INT; + $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr QUESTIONMARK expr COLON expr %prec QUESTIONMARK { $$.val = NewStringf("%s?%s:%s", $1.val, $3.val, $5.val); diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 3de794fdc..507c8c748 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -16,7 +16,8 @@ char cvsroot_scanner_c[] = "$Id$"; #include extern String *cparse_file; -extern int cparse_start_line; +extern int cparse_cplusplus; +extern int cparse_start_line; struct Scanner { String *text; /* Current token value */ @@ -730,15 +731,25 @@ static int look(Scanner * s) { break; case 7: /* Identifier */ if ((c = nextchar(s)) == 0) - return SWIG_TOKEN_ID; - if (isalnum(c) || (c == '_') || (c == '$')) { + state = 71; + else if (isalnum(c) || (c == '_') || (c == '$')) { state = 7; } else { retract(s, 1); - return SWIG_TOKEN_ID; + state = 71; } break; + case 71: /* Identifier or true/false */ + if (cparse_cplusplus) { + if (Strcmp(s->text, "true") == 0) + return SWIG_TOKEN_BOOL; + else if (Strcmp(s->text, "false") == 0) + return SWIG_TOKEN_BOOL; + } + return SWIG_TOKEN_ID; + break; + case 75: /* Special identifier $ */ if ((c = nextchar(s)) == 0) return SWIG_TOKEN_DOLLAR; @@ -747,7 +758,7 @@ static int look(Scanner * s) { } else { retract(s,1); if (Len(s->text) == 1) return SWIG_TOKEN_DOLLAR; - return SWIG_TOKEN_ID; + state = 71; } break; diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h index 3403098df..2adf7b2be 100644 --- a/Source/Swig/swigscan.h +++ b/Source/Swig/swigscan.h @@ -64,6 +64,7 @@ extern void Scanner_freeze_line(Scanner *s, int val); #define SWIG_TOKEN_ULONGLONG 29 /* 314ULL */ #define SWIG_TOKEN_QUESTION 30 /* ? */ #define SWIG_TOKEN_COMMENT 31 /* C or C++ comment */ +#define SWIG_TOKEN_BOOL 32 /* true or false */ #define SWIG_TOKEN_ILLEGAL 99 #define SWIG_TOKEN_ERROR -1 From 49935ee9524db96e00f7125834956c1fd83927cb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 2 Sep 2009 22:35:55 +0000 Subject: [PATCH 192/352] Fix director exception testcase since exception message recently changed slightly git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11678 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/director_exception_runme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py index ef7a044f1..82be1289b 100644 --- a/Examples/test-suite/python/director_exception_runme.py +++ b/Examples/test-suite/python/director_exception_runme.py @@ -43,7 +43,7 @@ b = launder(a) try: b.pong() except TypeError, e: - if str(e) == "Swig director type mismatch in output value of type 'std::string'": + if str(e) == "SWIG director type mismatch in output value of type 'std::string'": ok = 1 else: print "Unexpected error message: %s" % str(e) From fddbb30848a8c9fc12a9739d436371f1cc5c08ee Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Sep 2009 11:31:39 +0000 Subject: [PATCH 193/352] Revert removal of assertion. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11680 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 -- Lib/perl5/perlrun.swg | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 26f1434e1..6e7e6ba1a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -18,5 +18,3 @@ Version 1.3.41 (in progress) #define FOO true #define BAR FOO && false -2009-08-29: olly - [Perl] Remove bogus assertion (patch from David Fletcher). diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index 983633355..b506c3af9 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -293,6 +293,7 @@ SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_ int newmemory = 0; *ptr = SWIG_TypeCast(tc,voidptr,&newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { + assert(own); if (own) *own = *own | SWIG_CAST_NEW_MEMORY; } From 719cfe68bf161cf65a529da3138d3a12a3907304 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 7 Sep 2009 06:17:40 +0000 Subject: [PATCH 194/352] add some useful info for assert around SWIG_CAST_NEW_MEMORY git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11686 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/perl5/perlrun.swg | 2 +- Lib/python/pyrun.swg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index b506c3af9..ecb1f5cd2 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -293,7 +293,7 @@ SWIG_Perl_ConvertPtrAndOwn(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_ int newmemory = 0; *ptr = SWIG_TypeCast(tc,voidptr,&newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { - assert(own); + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ if (own) *own = *own | SWIG_CAST_NEW_MEMORY; } diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 21fddb610..c0d30ee45 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1089,7 +1089,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int int newmemory = 0; *ptr = SWIG_TypeCast(tc,vptr,&newmemory); if (newmemory == SWIG_CAST_NEW_MEMORY) { - assert(own); + assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */ if (own) *own = *own | SWIG_CAST_NEW_MEMORY; } From 2726424a7f4479682858f56fe54640d42a856a1c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 11 Sep 2009 18:47:05 +0000 Subject: [PATCH 195/352] Fix constant expressions containing <= or >= git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11687 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Doc/Manual/Library.html | 4 ++-- Examples/test-suite/csharp/preproc_constants_c_runme.cs | 2 ++ Examples/test-suite/csharp/preproc_constants_runme.cs | 2 ++ Examples/test-suite/preproc_constants.i | 4 ++-- Source/CParse/parser.y | 4 ++-- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6e7e6ba1a..5db53b965 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.41 (in progress) ============================ +2009-09-07: wsfulton + Fix constant expressions containing <= or >=. + 2009-09-02: wsfulton The following operators in constant expressions now result in type bool for C++ wrappers and remain as type int for C wrappers, as per each standard: diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 7293f31fe..eaebbede5 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -667,7 +667,7 @@ in order for this to work.

              -char *cdata(void *ptr, int nbytes) +const char *cdata(void *ptr, size_t nbytes)

              @@ -676,7 +676,7 @@ pointer.

              -void memmove(void *ptr, char *s) +void memmove(void *ptr, const char *s)

              diff --git a/Examples/test-suite/csharp/preproc_constants_c_runme.cs b/Examples/test-suite/csharp/preproc_constants_c_runme.cs index 71cf697f7..76c684d85 100644 --- a/Examples/test-suite/csharp/preproc_constants_c_runme.cs +++ b/Examples/test-suite/csharp/preproc_constants_c_runme.cs @@ -51,6 +51,8 @@ public class runme { 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() ); diff --git a/Examples/test-suite/csharp/preproc_constants_runme.cs b/Examples/test-suite/csharp/preproc_constants_runme.cs index b2c6c62ae..9fae5914a 100644 --- a/Examples/test-suite/csharp/preproc_constants_runme.cs +++ b/Examples/test-suite/csharp/preproc_constants_runme.cs @@ -50,6 +50,8 @@ public class runme { 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() ); diff --git a/Examples/test-suite/preproc_constants.i b/Examples/test-suite/preproc_constants.i index b759d8a75..771f3db1b 100644 --- a/Examples/test-suite/preproc_constants.i +++ b/Examples/test-suite/preproc_constants.i @@ -68,9 +68,9 @@ /* FIXME #define EXPR_LT 0xFF < 255 #define EXPR_GT 0xFF > 255 -#define EXPR_LTE 0xFF <= 255 -#define EXPR_LGE 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 diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 88e6a2005..99453b2fd 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -5620,11 +5620,11 @@ exprcompound : expr PLUS expr { /* Putting >= in the expression literally causes an infinite * loop somewhere in the type system. Just workaround for now * - SWIG_GE is defined in swiglabels.swg. */ - $$.val = NewStringf("%s SWIG_GE %s", $1.val, $3.val); + $$.val = NewStringf("%s >= %s", $1.val, $3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr LESSTHANOREQUALTO expr { - $$.val = NewStringf("%s SWIG_LE %s", $1.val, $3.val); + $$.val = NewStringf("%s <= %s", $1.val, $3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr QUESTIONMARK expr COLON expr %prec QUESTIONMARK { From a2229a45fc62cc6f6e0d6fa03819183c85f392b1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 11 Sep 2009 18:53:14 +0000 Subject: [PATCH 196/352] Fix memmove regression git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11688 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Examples/test-suite/li_cdata.i | 2 +- Examples/test-suite/python/li_cdata_runme.py | 10 ++++++++++ Lib/cdata.i | 3 ++- Lib/typemaps/cdata.swg | 5 +++-- 5 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 Examples/test-suite/python/li_cdata_runme.py diff --git a/CHANGES.current b/CHANGES.current index 5db53b965..d86107ca2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.41 (in progress) ============================ +2009-09-11: wsfulton + Fix memmove regression in cdata.i as reported by Adriaan Renting. + 2009-09-07: wsfulton Fix constant expressions containing <= or >=. diff --git a/Examples/test-suite/li_cdata.i b/Examples/test-suite/li_cdata.i index 6ce006d3b..2180af96e 100644 --- a/Examples/test-suite/li_cdata.i +++ b/Examples/test-suite/li_cdata.i @@ -5,4 +5,4 @@ %cdata(int); %cdata(double); - +void *malloc(size_t size); diff --git a/Examples/test-suite/python/li_cdata_runme.py b/Examples/test-suite/python/li_cdata_runme.py new file mode 100644 index 000000000..061ca6f68 --- /dev/null +++ b/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/Lib/cdata.i b/Lib/cdata.i index 67601f737..b970b1d5d 100644 --- a/Lib/cdata.i +++ b/Lib/cdata.i @@ -79,5 +79,6 @@ SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements); %cdata(void); -/* Memory move function */ +/* Memory move function. Due to multi-argument typemaps this appears to be wrapped as +void memmove(void *data, const char *s); */ void memmove(void *data, const void *indata, int inlen); diff --git a/Lib/typemaps/cdata.swg b/Lib/typemaps/cdata.swg index 32b3f5a77..cab53d31e 100644 --- a/Lib/typemaps/cdata.swg +++ b/Lib/typemaps/cdata.swg @@ -21,7 +21,7 @@ typedef struct SWIGCDATA { %typemap(out,noblock=1,fragment="SWIG_FromCharPtrAndSize") SWIGCDATA { %set_output(SWIG_FromCharPtrAndSize($1.data,$1.len)); } -%typemap(in) (const void *indata, int inlen) = (char *STRING, int SIZE); +%typemap(in) (const void *indata, size_t inlen) = (char *STRING, size_t SIZE); /* ----------------------------------------------------------------------------- @@ -70,7 +70,8 @@ SWIGCDATA cdata_##NAME(TYPE *ptr, size_t nelements = 1); %cdata(void); -/* Memory move function */ +/* Memory move function. Due to multi-argument typemaps this appears to be wrapped as +void memmove(void *data, const char *s); */ void memmove(void *data, const void *indata, size_t inlen); From 7df94f65e59c54c6ecca72269163a42eb3239f2f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Sat, 12 Sep 2009 08:23:55 +0000 Subject: [PATCH 197/352] Clean-up remnants of SWIG_GE, etc workaround which is no longer used. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11689 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 99453b2fd..cc795bd4f 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -5608,18 +5608,15 @@ exprcompound : expr PLUS expr { } /* Sadly this causes 2 reduce-reduce conflicts with templates. FIXME resolve these. | expr GREATERTHAN expr { - $$.val = NewStringf("%s SWIG_LT %s", $1.val, $3.val); + $$.val = NewStringf("%s < %s", $1.val, $3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } | expr LESSTHAN expr { - $$.val = NewStringf("%s SWIG_GT %s", $1.val, $3.val); + $$.val = NewStringf("%s > %s", $1.val, $3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } */ | expr GREATERTHANOREQUALTO expr { - /* Putting >= in the expression literally causes an infinite - * loop somewhere in the type system. Just workaround for now - * - SWIG_GE is defined in swiglabels.swg. */ $$.val = NewStringf("%s >= %s", $1.val, $3.val); $$.type = cparse_cplusplus ? T_BOOL : T_INT; } From 4ebb9b0db23127b42dbb39209f16c9d3263b3b21 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 13 Sep 2009 20:20:11 +0000 Subject: [PATCH 198/352] minor rewrite of enum value handling git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11690 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 4 ++-- Source/Modules/csharp.cxx | 30 ++++++++++++++++-------------- Source/Modules/java.cxx | 23 ++++++++++++----------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index cc795bd4f..8876384b1 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3127,8 +3127,8 @@ c_enum_decl : storage_class ENUM ename LBRACE enumlist RBRACE SEMI { if (unnamedinstance) { SwigType *cty = NewString("enum "); Setattr($$,"type",cty); - Setattr($$,"unnamedinstance","1"); - Setattr(n,"unnamedinstance","1"); + SetFlag($$,"unnamedinstance"); + SetFlag(n,"unnamedinstance"); Delete(cty); } if ($8) { diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index b5444d4b4..7c0114928 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1211,6 +1211,9 @@ public: String *symname = Getattr(n, "sym:name"); String *value = Getattr(n, "value"); String *name = Getattr(n, "name"); + Node *parent = parentNode(n); + int unnamedinstance = GetFlag(parent, "unnamedinstance"); + String *parent_name = Getattr(parent, "name"); String *tmpValue; // Strange hack from parent method @@ -1222,9 +1225,9 @@ public: Setattr(n, "value", tmpValue); { - EnumFeature enum_feature = decodeEnumFeature(parentNode(n)); + EnumFeature enum_feature = decodeEnumFeature(parent); - if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) { + if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) { // Wrap (non-anonymous) C/C++ enum with a proper C# enum // Emit the enum item. if (!GetFlag(n, "firstenumitem")) @@ -1241,21 +1244,16 @@ public: } } else { // Wrap C/C++ enums with constant integers or use the typesafe enum pattern - const String *parent_name = Getattr(parentNode(n), "name"); - String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int"); + String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */ + SwigType *typemap_lookup_type = parent_name ? parent_name : type; const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF); + String *return_type = Copy(tm); - Delete(typemap_lookup_type); - typemap_lookup_type = NULL; - - // The %csconst feature determines how the constant value is obtained - int const_feature_flag = GetFlag(n, "feature:cs:const"); - const String *methodmods = Getattr(n, "feature:cs:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); - if ((enum_feature == TypesafeEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) { - // Wrap (non-anonymouse) enum using the typesafe enum pattern + if ((enum_feature == TypesafeEnum) && parent_name && !unnamedinstance) { + // Wrap (non-anonymous) enum using the typesafe enum pattern if (Getattr(n, "enumvalue")) { String *value = enumValue(n); Printf(enum_code, " %s static readonly %s %s = new %s(\"%s\", %s);\n", methodmods, return_type, symname, return_type, symname, value); @@ -1267,6 +1265,10 @@ public: // Simple integer constants // Note these are always generated for anonymous enums, no matter what enum_feature is specified // Code generated is the same for SimpleEnum and TypeunsafeEnum -> the class it is generated into is determined later + + // The %csconst feature determines how the constant value is obtained + int const_feature_flag = GetFlag(n, "feature:cs:const"); + const char *const_readonly = const_feature_flag ? "const" : "static readonly"; String *value = enumValue(n); Printf(enum_code, " %s %s %s %s = %s;\n", methodmods, const_readonly, return_type, symname, value); @@ -1275,9 +1277,9 @@ public: } // Add the enum value to the comma separated list being constructed in the enum declaration. - String *enumvalues = Getattr(parentNode(n), "enumvalues"); + String *enumvalues = Getattr(parent, "enumvalues"); if (!enumvalues) - Setattr(parentNode(n), "enumvalues", Copy(symname)); + Setattr(parent, "enumvalues", Copy(symname)); else Printv(enumvalues, ", ", symname, NIL); } diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 9af6fc214..fd6c768c9 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1267,6 +1267,9 @@ public: String *symname = Getattr(n, "sym:name"); String *value = Getattr(n, "value"); String *name = Getattr(n, "name"); + Node *parent = parentNode(n); + int unnamedinstance = GetFlag(parent, "unnamedinstance"); + String *parent_name = Getattr(parent, "name"); String *tmpValue; // Strange hack from parent method @@ -1278,9 +1281,9 @@ public: Setattr(n, "value", tmpValue); { - EnumFeature enum_feature = decodeEnumFeature(parentNode(n)); + EnumFeature enum_feature = decodeEnumFeature(parent); - if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) { + if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) { // Wrap (non-anonymous) C/C++ enum with a proper Java enum // Emit the enum item. if (!GetFlag(n, "firstenumitem")) @@ -1293,18 +1296,16 @@ public: } } else { // Wrap C/C++ enums with constant integers or use the typesafe enum pattern - const String *parent_name = Getattr(parentNode(n), "name"); - String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int"); + String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */ + SwigType *typemap_lookup_type = parent_name ? parent_name : type; const String *tm = typemapLookup(n, "jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF); - String *return_type = Copy(tm); - Delete(typemap_lookup_type); - typemap_lookup_type = NULL; + String *return_type = Copy(tm); const String *methodmods = Getattr(n, "feature:java:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); - if ((enum_feature == TypesafeEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) { - // Wrap (non-anonymouse) enum using the typesafe enum pattern + if ((enum_feature == TypesafeEnum) && parent_name && !unnamedinstance) { + // Wrap (non-anonymous) enum using the typesafe enum pattern if (Getattr(n, "enumvalue")) { String *value = enumValue(n); Printf(enum_code, " %s final static %s %s = new %s(\"%s\", %s);\n", methodmods, return_type, symname, return_type, symname, value); @@ -1323,9 +1324,9 @@ public: } // Add the enum value to the comma separated list being constructed in the enum declaration. - String *enumvalues = Getattr(parentNode(n), "enumvalues"); + String *enumvalues = Getattr(parent, "enumvalues"); if (!enumvalues) - Setattr(parentNode(n), "enumvalues", Copy(symname)); + Setattr(parent, "enumvalues", Copy(symname)); else Printv(enumvalues, ", ", symname, NIL); } From 5eeab68e21a8b68c5025ab791a6ac2f7d28000ff Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Sep 2009 19:37:55 +0000 Subject: [PATCH 199/352] Add %csattributes for adding C# attributes to enum values, see docs for example. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11691 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ .../csharp/csharp_attributes_runme.cs | 19 +++++++++++++++++++ Examples/test-suite/csharp_attributes.i | 4 ++++ Source/Modules/csharp.cxx | 8 ++++++++ 4 files changed, 34 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index d86107ca2..1f6de8059 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.41 (in progress) ============================ +2009-09-14: wsfulton + [C#] Add %csattributes for adding C# attributes to enum values, see docs for example. + 2009-09-11: wsfulton Fix memmove regression in cdata.i as reported by Adriaan Renting. diff --git a/Examples/test-suite/csharp/csharp_attributes_runme.cs b/Examples/test-suite/csharp/csharp_attributes_runme.cs index 7dc9d7c87..3f4ea179a 100644 --- a/Examples/test-suite/csharp/csharp_attributes_runme.cs +++ b/Examples/test-suite/csharp/csharp_attributes_runme.cs @@ -1,5 +1,6 @@ using System; using System.Reflection; +using System.ComponentModel; using csharp_attributesNamespace; public class runme @@ -171,6 +172,24 @@ public class runme 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); diff --git a/Examples/test-suite/csharp_attributes.i b/Examples/test-suite/csharp_attributes.i index 101e89732..e74f7422d 100644 --- a/Examples/test-suite/csharp_attributes.i +++ b/Examples/test-suite/csharp_attributes.i @@ -15,6 +15,8 @@ public: int GlobalFunction(int myInt) { return myInt; } %} +//%include "enumsimple.swg" +//%include "enumtypesafe.swg" // Test the attributes feature %csattributes MoreStations::MoreStations() "[InterCity1]" @@ -25,6 +27,8 @@ int GlobalFunction(int myInt) { return myInt; } %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]" diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 7c0114928..a752fb933 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1226,12 +1226,17 @@ public: { EnumFeature enum_feature = decodeEnumFeature(parent); + const String *csattributes = Getattr(n, "feature:cs:attributes"); if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) { // Wrap (non-anonymous) C/C++ enum with a proper C# enum // Emit the enum item. if (!GetFlag(n, "firstenumitem")) Printf(enum_code, ",\n"); + + if (csattributes) + Printf(enum_code, " %s\n", csattributes); + Printf(enum_code, " %s", symname); // Check for the %csconstvalue feature @@ -1252,6 +1257,9 @@ public: const String *methodmods = Getattr(n, "feature:cs:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); + if (csattributes) + Printf(enum_code, " %s\n", csattributes); + if ((enum_feature == TypesafeEnum) && parent_name && !unnamedinstance) { // Wrap (non-anonymous) enum using the typesafe enum pattern if (Getattr(n, "enumvalue")) { From 272ed9fc29e670648ad2e0e6dda4f7a69b22cd03 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Tue, 15 Sep 2009 01:27:17 +0000 Subject: [PATCH 200/352] require -fPIC in compile line git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11692 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 16f3cfbe2..561f7cc29 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1124,11 +1124,11 @@ RRSRC = $(INTERFACE:.i=.R) r: $(SRCS) $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) - +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) + +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o -fPIC $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) r_cpp: $(CXXSRCS) $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) - +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) ) + +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -fPIC -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) ) r_clean: rm -f *_wrap* *~ .~* From 15070e6d8fb55b308ca0035fb77f1ffb55ec34c3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 Sep 2009 21:26:57 +0000 Subject: [PATCH 201/352] Add %csattributes for adding C# attributes to enum values. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11693 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index f092d188a..be0dcf658 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -297,7 +297,7 @@ Note that all these different C# attributes can be combined so that a method has

            • -Support for attaching C# attributes to wrapped methods and variables. +Support for attaching C# attributes to wrapped methods, variables and enum values. This is done using the %csattributes feature, see %feature directives. Note that C# attributes are attached to proxy classes and enums using the csattributes typemap. For example, imagine we have a custom attribute class, ThreadSafeAttribute, for labelling thread safety. @@ -344,6 +344,38 @@ they can be added using the 'csvarin' and 'csvarout' typemaps respectively. Note that the type used for the property is specified in the 'cstype' typemap. If the 'out' attribute exists in this typemap, then the type used is from the 'out' attribute.

              + +

              +An example for attaching attributes to the enum and enum values is shown below. +

              + +
              +
              +%typemap(csattributes) Couleur "[System.ComponentModel.Description(\"Colours\")]"
              +%csattributes Rouge "[System.ComponentModel.Description(\"Red\")]"
              +%csattributes Vert "[System.ComponentModel.Description(\"Green\")]"
              +%inline %{
              +  enum Couleur { Rouge, Orange, Vert };
              +%}
              +
              +
              + +

              +which will result in the following C# enum: +

              + +
              +
              +[System.ComponentModel.Description("Colours")]
              +public enum Couleur {
              +  [System.ComponentModel.Description("Red")]
              +  Rouge,
              +  Orange,
              +  [System.ComponentModel.Description("Green")]
              +  Vert
              +}
              +
              +
            • From 123f4931cd9efd04f5375553a05cbeeb086b58aa Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 1 Oct 2009 18:16:09 +0000 Subject: [PATCH 202/352] document directorinattributes and directoroutattributes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11696 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 9 ++++++++- .../test-suite/csharp/csharp_attributes_runme.cs | 8 ++++++++ Examples/test-suite/csharp_attributes.i | 12 +++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index be0dcf658..a4bb9e2d1 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -249,7 +249,9 @@ public static extern IntPtr function(string jarg1);

              Support for type attributes. The 'imtype' and 'cstype' typemaps can have an optional inattributes and outattributes typemap attribute. -There are C# attributes and typemap attributes, don't get confused!! +The 'imtype' typemap can also have an optional directorinattributes and directoroutattributes +typemap attribute which attaches to director delegates, an implementation detail of directors, see directors implementation. +Note that there are C# attributes and typemap attributes, don't get confused between the two!! The C# attributes specified in these typemap attributes are generated wherever the type is used in the C# wrappers. These can be used to specify any C# attribute associated with a C/C++ type, but are more typically used for the C# MarshalAs attribute. For example: @@ -293,6 +295,11 @@ These attributes are associated with the C/C++ parameter type or return type, wh the attribute features and typemaps covered next. Note that all these different C# attributes can be combined so that a method has more than one attribute.

              + +

              +The directorinattributes and directoroutattributes typemap attribute are attached to the delegates in the director class, for example, the SwigDelegateBase_0 +

              +
            • diff --git a/Examples/test-suite/csharp/csharp_attributes_runme.cs b/Examples/test-suite/csharp/csharp_attributes_runme.cs index 3f4ea179a..4cdced80d 100644 --- a/Examples/test-suite/csharp/csharp_attributes_runme.cs +++ b/Examples/test-suite/csharp/csharp_attributes_runme.cs @@ -198,6 +198,8 @@ public class runme if (tgv == null) throw new Exception("No attribute for Cymru"); } + + // No runtime test for directorinattributes and directoroutattributes } } @@ -256,3 +258,9 @@ public class ThreadSafeAttribute : Attribute { 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/Examples/test-suite/csharp_attributes.i b/Examples/test-suite/csharp_attributes.i index e74f7422d..bca595d9a 100644 --- a/Examples/test-suite/csharp_attributes.i +++ b/Examples/test-suite/csharp_attributes.i @@ -1,4 +1,4 @@ -%module csharp_attributes +%module(directors="1") csharp_attributes // Test the inattributes and outattributes typemaps %typemap(cstype, outattributes="[IntOut]", inattributes="[IntIn]") int "int" @@ -50,3 +50,13 @@ 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() {} +}; +%} From 4b2ced5095ea8ee40d9d13d36c939374d820e52b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Oct 2009 17:50:36 +0000 Subject: [PATCH 203/352] Fix partial specialization and explicit specialization lookup git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11703 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 21 + Examples/test-suite/common.mk | 2 + ...template_partial_specialization_runme.java | 59 ++ ..._partial_specialization_typedef_runme.java | 59 ++ .../template_partial_specialization.i | 134 +++++ .../template_partial_specialization_typedef.i | 130 +++++ Source/CParse/parser.y | 19 +- Source/CParse/templ.c | 512 +++++++++++++----- 8 files changed, 784 insertions(+), 152 deletions(-) create mode 100644 Examples/test-suite/java/template_partial_specialization_runme.java create mode 100644 Examples/test-suite/java/template_partial_specialization_typedef_runme.java create mode 100644 Examples/test-suite/template_partial_specialization.i create mode 100644 Examples/test-suite/template_partial_specialization_typedef.i diff --git a/CHANGES.current b/CHANGES.current index 1f6de8059..16d5c6c28 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,27 @@ Version 1.3.41 (in progress) ============================ +2009-10-20: wsfulton + Fixed previously fairly poor template partial specialization and explicit + specialization support. Numerous bugs in this area have been fixed including: + + - Template argument deduction implemented for template type arguments, eg this now + works: + template class X {}; + template class X {}; + %template(X1) X; // Chooses T * specialization + + and more complex cases with multiple parameters and a mix of template argument + deduction and explicitly specialised parameters, eg: + template struct TwoParm { void a() {} }; + template struct TwoParm { void e() {} }; + %template(E) TwoParm; + + Note that the primary template must now be in scope, like in C++, when + an explicit or partial specialization is instantiated with %template. + + *** POTENTIAL INCOMPATIBILITY *** + 2009-09-14: wsfulton [C#] Add %csattributes for adding C# attributes to enum values, see docs for example. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 4bbf74525..a47f821ef 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -339,6 +339,8 @@ CPP_TEST_CASES += \ template_ns_inherit \ template_ns_scope \ template_partial_arg \ + template_partial_specialization \ + template_partial_specialization_typedef \ template_qualifier \ template_qualifier \ template_ref_type \ diff --git a/Examples/test-suite/java/template_partial_specialization_runme.java b/Examples/test-suite/java/template_partial_specialization_runme.java new file mode 100644 index 000000000..ef8c4e80e --- /dev/null +++ b/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/Examples/test-suite/java/template_partial_specialization_typedef_runme.java b/Examples/test-suite/java/template_partial_specialization_typedef_runme.java new file mode 100644 index 000000000..6ae95eb6a --- /dev/null +++ b/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/Examples/test-suite/template_partial_specialization.i b/Examples/test-suite/template_partial_specialization.i new file mode 100644 index 000000000..e59ae7e5a --- /dev/null +++ b/Examples/test-suite/template_partial_specialization.i @@ -0,0 +1,134 @@ +%module template_partial_specialization + +%inline %{ +namespace One { + template struct OneParm { void a() {} }; + template struct OneParm { void b() {} }; + template struct OneParm { void c() {} }; + template struct OneParm { void d() {} }; + template struct OneParm { void e() {} }; + + template <> struct OneParm { void f() {} }; + template <> struct OneParm { void g() {} }; + template <> struct OneParm { void h() {} }; + + template <> struct OneParm { void i() {} }; + template <> struct OneParm { void j() {} }; + template <> struct OneParm { void k() {} }; + template <> struct OneParm { void l() {} }; +} +%} + +// partial specializations +%template(A) One::OneParm; +%template(B) One::OneParm; +%template(C) One::OneParm; +%template(D) One::OneParm; +%template(E) One::OneParm; + +// explicit specializations +%template(F) One::OneParm; +%template(G) One::OneParm; +%template(H) One::OneParm; + +// %template scope explicit specializations +namespace ONE { + %template(I) One::OneParm; + %template(J) ::One::OneParm; +} +%template(K) ::One::OneParm; +namespace One { + %template(L) OneParm; +} + +// %template scope partial specializations +namespace ONE { + %template(BB) One::OneParm; + %template(BBB) ::One::OneParm; +} +%template(BBBB) ::One::OneParm; +namespace One { + %template(BBBBB) OneParm; +} + +// non-exact match +%template(B1) One::OneParm; +%template(B2) One::OneParm; +%template(B3) One::OneParm; +%template(B4) One::OneParm; + + +// Two parameter specialization tests +%inline %{ +struct Concrete {}; +namespace Two { + template struct TwoParm { void a() {} }; + template struct TwoParm { void b() {} }; + template struct TwoParm { void c() {} }; + template struct TwoParm { void d() {} }; + template struct TwoParm { void e() {} }; + template struct TwoParm { void f() {} }; + template <> struct TwoParm { void g() {} }; +} +%} + +namespace Two { + %template(A_) TwoParm; + %template(B_) TwoParm; + %template(C_) TwoParm; + %template(D_) TwoParm; + %template(E_) TwoParm; + %template(F_) TwoParm; + %template(G_) TwoParm; + + %template(C1_) TwoParm; + %template(C2_) TwoParm; +} + +%template(C3_) Two::TwoParm; +%template(C4_) ::Two::TwoParm; +%template(B1_) ::Two::TwoParm; +%template(E1_) Two::TwoParm; +%template(E2_) Two::TwoParm; + +#if 0 +// TODO fix: +%inline %{ +//namespace S { + template struct X { void a() {} }; + template struct X { void b() {} }; +// template<> struct X { void c() {} }; +//} +%} + +#if 0 +struct AA { // crashes +#else +namespace AA { // thinks X is in AA namespace + %template(X2) X; +}; +#endif +#endif + +#if 0 +namespace Space { +} +template struct Vector { +#ifdef SWIG + %template() Space::VectorHelper; +#endif + void gook(T i) {} + void geeko(double d) {} + void geeky(int d) {} +}; +/* +template struct Vector { +}; +*/ +//} +%} + +%template(VectorIntPtr) Space::Vector; // 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/Examples/test-suite/template_partial_specialization_typedef.i b/Examples/test-suite/template_partial_specialization_typedef.i new file mode 100644 index 000000000..6fdbf99aa --- /dev/null +++ b/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 struct OneParm { void a() {} }; + template struct OneParm { void b() {} }; + template struct OneParm { void c() {} }; + template struct OneParm { void d() {} }; + template struct OneParm { void e() {} }; + + template <> struct OneParm { void f() {} }; + template <> struct OneParm { void g() {} }; + template <> struct OneParm { void h() {} }; + + template <> struct OneParm { void i() {} }; + template <> struct OneParm { void j() {} }; + template <> struct OneParm { void k() {} }; + template <> struct OneParm { void l() {} }; +} +%} + +// partial specializations +%template(A) One::OneParm; +%template(B) One::OneParm; +%template(C) One::OneParm; +%template(D) One::OneParm; +%template(E) One::OneParm; + +// explicit specializations +%template(F) One::OneParm; +%template(G) One::OneParm; +%template(H) One::OneParm; + +// %template scope explicit specializations +namespace ONE { + %template(I) One::OneParm; + %template(J) ::One::OneParm; +} +%template(K) ::One::OneParm; +namespace One { + %template(L) OneParm; +} + +// %template scope partial specializations +namespace ONE { + %template(BB) One::OneParm; + %template(BBB) ::One::OneParm; +} +%template(BBBB) ::One::OneParm; +namespace One { + %template(BBBBB) OneParm; +} + +// non-exact match +%template(B1) One::OneParm; +%template(B2) One::OneParm; +%template(B3) One::OneParm; +%template(B4) One::OneParm; + + +// Two parameter specialization tests +%inline %{ +struct Concrete {}; +namespace Two { + template struct TwoParm { void a() {} }; + template struct TwoParm { void b() {} }; + template struct TwoParm { void c() {} }; + template struct TwoParm { void d() {} }; + template struct TwoParm { void e() {} }; + template struct TwoParm { void f() {} }; + template <> struct TwoParm { void g() {} }; +} +%} + +%inline %{ +namespace TypeDef { + typedef const double * ConstDoublePtr; + typedef const int * ConstIntPtr; + typedef int * IntPtr; + typedef Concrete * ConcretePtr; + typedef const Concrete * ConstConcretePtr; + typedef void * VoidPtr; +} +%} +namespace Two { + %template(A_) TwoParm; + %template(B_) TwoParm; + %template(C_) TwoParm; + %template(D_) TwoParm; + %template(E_) TwoParm; + %template(F_) TwoParm; + %template(G_) TwoParm; + + %template(C1_) TwoParm; + %template(C2_) TwoParm; +} + +%template(C3_) Two::TwoParm; +%template(C4_) ::Two::TwoParm; +%template(B1_) ::Two::TwoParm; +%template(E1_) Two::TwoParm; +%template(E2_) Two::TwoParm; + diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 8876384b1..29aff3d10 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3759,6 +3759,7 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para Parm *p = $3; String *fname = NewString(Getattr($$,"name")); String *ffname = 0; + ParmList *partialparms = 0; char tmp[32]; int i, ilen; @@ -3780,12 +3781,21 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para /* Patch argument names with typedef */ { Iterator tt; + Parm *parm_current = 0; List *tparms = SwigType_parmlist(fname); ffname = SwigType_templateprefix(fname); Append(ffname,"<("); for (tt = First(tparms); tt.item; ) { SwigType *rtt = Swig_symbol_typedef_reduce(tt.item,0); SwigType *ttr = Swig_symbol_type_qualify(rtt,0); + + Parm *newp = NewParm(ttr, 0); + if (partialparms) + set_nextSibling(partialparms, newp); + else + partialparms = newp; + parm_current = newp; + Append(ffname,ttr); tt = Next(tt); if (tt.item) Putc(',',ffname); @@ -3796,6 +3806,7 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para Append(ffname,")>"); } { + Node *new_partial = NewHash(); String *partials = Getattr(tempn,"partials"); if (!partials) { partials = NewList(); @@ -3803,7 +3814,9 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para Delete(partials); } /* Printf(stdout,"partial: fname = '%s', '%s'\n", fname, Swig_symbol_typedef_reduce(fname,0)); */ - Append(partials,ffname); + Setattr(new_partial, "partialparms", partialparms); + Setattr(new_partial, "templcsymname", ffname); + Append(partials, new_partial); } Setattr($$,"partialargs",ffname); Swig_symbol_cadd(ffname,$$); @@ -3812,8 +3825,8 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para Delete(tlist); Delete(targs); } else { - /* Need to resolve exact specialization name */ - /* add default args from generic template */ + /* An explicit template specialization */ + /* add default args from primary (unspecialized) template */ String *ty = Swig_symbol_template_deftype(tname,0); String *fname = Swig_symbol_type_qualify(ty,0); Swig_symbol_cadd(fname,$$); diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index 14886605f..1f1620094 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -422,6 +422,70 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab return 0; } +typedef enum { ExactNoMatch = -2, PartiallySpecializedNoMatch = -1, PartiallySpecializedMatch = 1, ExactMatch = 2 } EMatch; + +/* ----------------------------------------------------------------------------- + * does_parm_match() + * + * Template argument deduction - check if a template type matches a partially specialized + * template parameter type. Reduce 'partial_parm_type' to see if it matches 'type'. + * + * type - template parameter type to match against + * partial_parm_type - partially specialized template type - a possible match + * partial_parm_type_base - base type of partial_parm_type + * tscope - template scope + * specialization_priority - (output) contains a value indicating how good the match is + * (higher is better) only set if return is set to PartiallySpecializedMatch or ExactMatch. + * ----------------------------------------------------------------------------- */ + +static EMatch does_parm_match(SwigType *type, SwigType *partial_parm_type, const char *partial_parm_type_base, Symtab *tscope, int *specialization_priority) { + static const int EXACT_MATCH_PRIORITY = 99999; /* a number bigger than the length of any conceivable type */ + int matches; + int substitutions; + EMatch match; + SwigType *ty = Swig_symbol_typedef_reduce(type, tscope); + String *base = SwigType_base(ty); + SwigType *t = Copy(partial_parm_type); + substitutions = Replaceid(t, partial_parm_type_base, base); /* eg: Replaceid("p.$1", "$1", "int") returns t="p.int" */ + matches = Equal(ty, t); + *specialization_priority = -1; + if (substitutions == 1) { + /* we have a non-explicit specialized parameter (in partial_parm_type) because a substitution for $1, $2... etc has taken place */ + SwigType *tt = Copy(partial_parm_type); + int len; + /* + check for match to partial specialization type, for example, all of the following could match the type in the %template: + template struct XX {}; + template struct XX {}; // r.$1 + template struct XX {}; // r.q(const).$1 + template struct XX {}; // r.q(const).p.$1 + %template(XXX) XX; // r.q(const).p.int + + where type="r.q(const).p.int" will match either of tt="r.$1", tt="r.q(const)" tt="r.q(const).p" + */ + Replaceid(tt, partial_parm_type_base, ""); /* remove the $1, $2 etc, eg tt="p.$1" => "p." */ + len = Len(tt); + if (Strncmp(tt, ty, len) == 0) { + match = PartiallySpecializedMatch; + *specialization_priority = len; + } else { + match = PartiallySpecializedNoMatch; + } + Delete(tt); + } else { + match = matches ? ExactMatch : ExactNoMatch; + if (matches) + *specialization_priority = EXACT_MATCH_PRIORITY; /* exact matches always take precedence */ + } + /* + Printf(stdout, " does_parm_match %2d %5d [%s] [%s]\n", match, *specialization_priority, type, partial_parm_type); + */ + Delete(t); + Delete(base); + Delete(ty); + return match; +} + /* ----------------------------------------------------------------------------- * template_locate() * @@ -429,175 +493,321 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab * ----------------------------------------------------------------------------- */ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) { - Node *n; - String *tname, *rname = 0; + Node *n = 0; + String *tname = 0, *rname = 0; Node *templ; - List *mpartials = 0; + Symtab *primary_scope = 0; + List *possiblepartials = 0; Parm *p; - Parm *parms; + Parm *parms = 0; Parm *targs; ParmList *expandedparms; + int *priorities_matrix = 0; + int max_possible_partials = 0; + int posslen = 0; - tname = Copy(name); - parms = CopyParmList(tparms); - - /* Search for generic template */ + /* Search for primary (unspecialized) template */ templ = Swig_symbol_clookup(name, 0); - /* Add default values from generic template */ - if (templ) { - Symtab *tsdecl = Getattr(templ, "sym:symtab"); + if (template_debug) { + tname = Copy(name); + SwigType_add_template(tname, tparms); + Printf(stdout, "\n%s:%d: template_debug: Searching for match to: '%s'\n", cparse_file, cparse_line, tname); + Delete(tname); + tname = 0; + } + if (templ) { + tname = Copy(name); + parms = CopyParmList(tparms); + + /* All template specializations must be in the primary template's scope, store the symbol table for this scope for specialization lookups */ + primary_scope = Getattr(templ, "sym:symtab"); + + /* Add default values from primary template */ targs = Getattr(templ, "templateparms"); - expandedparms = Swig_symbol_template_defargs(parms, targs, tscope, tsdecl); - } else { - expandedparms = parms; - } + expandedparms = Swig_symbol_template_defargs(parms, targs, tscope, primary_scope); - - /* reduce the typedef */ - p = expandedparms; - while (p) { - SwigType *ty = Getattr(p, "type"); - if (ty) { - SwigType *nt = Swig_symbol_type_qualify(ty, tscope); - Setattr(p, "type", nt); - Delete(nt); - } - p = nextSibling(p); - } - - SwigType_add_template(tname, expandedparms); - - if (template_debug) { - Printf(stdout, "\n%s:%d: template_debug: Searching for %s\n", cparse_file, cparse_line, tname); - } - - /* Search for an exact specialization. - Example: template<> class name { ... } */ - { - if (template_debug) { - Printf(stdout, " searching: '%s' (exact specialization)\n", tname); - } - n = Swig_symbol_clookup_local(tname, 0); - if (!n) { - SwigType *rname = Swig_symbol_typedef_reduce(tname, tscope); - if (!Equal(rname, tname)) { - if (template_debug) { - Printf(stdout, " searching: '%s' (exact specialization)\n", rname); - } - n = Swig_symbol_clookup_local(rname, 0); + /* reduce the typedef */ + p = expandedparms; + while (p) { + SwigType *ty = Getattr(p, "type"); + if (ty) { + SwigType *nt = Swig_symbol_type_qualify(ty, tscope); + Setattr(p, "type", nt); + Delete(nt); } - Delete(rname); + p = nextSibling(p); } - if (n) { - Node *tn; - String *nodeType = nodeType(n); - if (Equal(nodeType, "template")) - goto success; - tn = Getattr(n, "template"); - if (tn) { - n = tn; - goto success; /* Previously wrapped by a template return that */ + SwigType_add_template(tname, expandedparms); + + /* Search for an explicit (exact) specialization. Example: template<> class name { ... } */ + { + if (template_debug) { + Printf(stdout, " searching for : '%s' (explicit specialization)\n", tname); } - Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, nodeType(n)); - Delete(tname); - Delete(parms); - return 0; /* Found a match, but it's not a template of any kind. */ - } - } - - /* Search for partial specialization. - Example: template class name { ... } */ - - /* Generate reduced template name (stripped of extraneous pointers, etc.) */ - - rname = NewStringf("%s<(", name); - p = parms; - while (p) { - String *t; - t = Getattr(p, "type"); - if (!t) - t = Getattr(p, "value"); - if (t) { - String *ty = Swig_symbol_typedef_reduce(t, tscope); - String *tb = SwigType_base(ty); - String *td = SwigType_default(ty); - Replaceid(td, "enum SWIGTYPE", tb); - Replaceid(td, "SWIGTYPE", tb); - Append(rname, td); - Delete(tb); - Delete(ty); - Delete(td); - } - p = nextSibling(p); - if (p) { - Append(rname, ","); - } - } - Append(rname, ")>"); - - mpartials = NewList(); - if (templ) { - /* First, we search using an exact type prototype */ - Parm *p; - char tmp[32]; - int i; - List *partials; - String *ss; - Iterator pi; - - partials = Getattr(templ, "partials"); - if (partials) { - for (pi = First(partials); pi.item; pi = Next(pi)) { - ss = Copy(pi.item); - p = parms; - i = 1; - while (p) { - String *t, *tn; - sprintf(tmp, "$%d", i); - t = Getattr(p, "type"); - if (!t) - t = Getattr(p, "value"); - if (t) { - String *ty = Swig_symbol_typedef_reduce(t, tscope); - tn = SwigType_base(ty); - Replaceid(ss, tmp, tn); - Delete(tn); - Delete(ty); + n = Swig_symbol_clookup_local(tname, primary_scope); + if (!n) { + SwigType *rname = Swig_symbol_typedef_reduce(tname, tscope); + if (!Equal(rname, tname)) { + if (template_debug) { + Printf(stdout, " searching for : '%s' (explicit specialization with typedef reduction)\n", rname); } - i++; - p = nextSibling(p); + n = Swig_symbol_clookup_local(rname, primary_scope); } - if (template_debug) { - Printf(stdout, " searching: '%s' (partial specialization - %s)\n", ss, pi.item); - } - if ((Equal(ss, tname)) || (Equal(ss, rname))) { - Append(mpartials, pi.item); - } - Delete(ss); + Delete(rname); } - } - } - - if (template_debug) { - Printf(stdout, " Matched partials: %s\n", mpartials); - } - - if (Len(mpartials)) { - String *s = Getitem(mpartials, 0); - n = Swig_symbol_clookup_local(s, 0); - if (Len(mpartials) > 1) { if (n) { - Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, cparse_file, cparse_line, "Instantiation of template '%s' is ambiguous,\n", SwigType_namestr(tname)); - Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, Getfile(n), Getline(n), " instantiation '%s' is used.\n", SwigType_namestr(Getattr(n, "name"))); + Node *tn; + String *nodeType = nodeType(n); + if (Equal(nodeType, "template")) { + if (template_debug) { + Printf(stdout, " explicit specialization found: '%s'\n", Getattr(n, "name")); + } + goto success; + } + tn = Getattr(n, "template"); + if (tn) { + if (template_debug) { + Printf(stdout, " previous instantiation found: '%s'\n", Getattr(n, "name")); + } + n = tn; + goto success; /* Previously wrapped by a template instantiation */ + } + Swig_error(cparse_file, cparse_line, "'%s' is not defined as a template. (%s)\n", name, nodeType(n)); + Delete(tname); + Delete(parms); + return 0; /* Found a match, but it's not a template of any kind. */ } } + + /* Search for partial specializations. + * Example: template class name { ... } + + * There are 3 types of template arguments: + * (1) Template type arguments + * (2) Template non type arguments + * (3) Template template arguments + * only (1) is really supported for partial specializations + */ + + /* Generate reduced template name (stripped of extraneous pointers, etc.) */ + rname = NewStringf("%s<(", name); + p = parms; + while (p) { + String *t; + t = Getattr(p, "type"); + if (!t) + t = Getattr(p, "value"); + if (t) { + String *tyr = Swig_symbol_typedef_reduce(t, tscope); + String *ty = SwigType_strip_qualifiers(tyr); + String *tb = SwigType_base(ty); + String *td = SwigType_default(ty); + Replaceid(td, "enum SWIGTYPE", tb); + Replaceid(td, "SWIGTYPE", tb); + Append(rname, td); + Delete(tb); + Delete(td); + Delete(ty); + Delete(tyr); + } + p = nextSibling(p); + if (p) { + Append(rname, ","); + } + } + Append(rname, ")>"); + + /* Rank each template parameter against the desired template parameters then build a matrix of best matches */ + possiblepartials = NewList(); + { + char tmp[32]; + List *partials; + + partials = Getattr(templ, "partials"); /* note that these partial specializations do not include explicit specializations */ + if (partials) { + Iterator pi; + int parms_len = ParmList_len(parms); + int *priorities_row; + max_possible_partials = Len(partials); + priorities_matrix = (int *)malloc(sizeof(int) * max_possible_partials * parms_len); /* slightly wasteful allocation for max possible matches */ + priorities_row = priorities_matrix; + for (pi = First(partials); pi.item; pi = Next(pi)) { + Parm *p = parms; + int all_parameters_match = 1; + int i = 1; + Parm *partialparms = Getattr(pi.item, "partialparms"); + Parm *pp = partialparms; + String *templcsymname = Getattr(pi.item, "templcsymname"); + if (template_debug) { + Printf(stdout, " checking match: '%s' (partial specialization)\n", templcsymname); + } + if (ParmList_len(partialparms) == parms_len) { + while (p && pp) { + SwigType *t; + sprintf(tmp, "$%d", i); + t = Getattr(p, "type"); + if (!t) + t = Getattr(p, "value"); + if (t) { + EMatch match = does_parm_match(t, Getattr(pp, "type"), tmp, tscope, priorities_row + i - 1); + if (match < (int)PartiallySpecializedMatch) { + all_parameters_match = 0; + break; + } + } + i++; + p = nextSibling(p); + pp = nextSibling(pp); + } + if (all_parameters_match) { + Append(possiblepartials, pi.item); + priorities_row += parms_len; + } + } + } + } + } + + posslen = Len(possiblepartials); + if (template_debug) { + int i; + if (posslen == 0) + Printf(stdout, " matched partials: NONE\n"); + else if (posslen == 1) + Printf(stdout, " chosen partial: '%s'\n", Getattr(Getitem(possiblepartials, 0), "templcsymname")); + else { + Printf(stdout, " possibly matched partials:\n"); + for (i = 0; i < posslen; i++) { + Printf(stdout, " '%s'\n", Getattr(Getitem(possiblepartials, i), "templcsymname")); + } + } + } + + if (posslen > 1) { + /* Now go through all the possibly matched partial specialization templates and look for a non-ambiguous match. + * Exact matches rank the highest and deduced parameters are ranked by how much they are reduced, eg looking for + * a match to const int *, the following rank (highest to lowest): + * const int * (exact match) + * const T * + * T * + * T + * + * An ambiguous example when attempting to match as either specialization could match: %template() X; + * template X class {}; // primary template + * template X class {}; // specialization (1) + * template X class {}; // specialization (2) + */ + if (template_debug) { + int row, col; + int parms_len = ParmList_len(parms); + Printf(stdout, " parameter priorities matrix (%d parms):\n", parms_len); + for (row = 0; row < posslen; row++) { + int *priorities_row = priorities_matrix + row*parms_len; + Printf(stdout, " "); + for (col = 0; col < parms_len; col++) { + Printf(stdout, "%5d ", priorities_row[col]); + } + Printf(stdout, "\n"); + } + } + { + int row, col; + int parms_len = ParmList_len(parms); + /* Printf(stdout, " parameter priorities inverse matrix (%d parms):\n", parms_len); */ + for (col = 0; col < parms_len; col++) { + int *priorities_col = priorities_matrix + col; + int maxpriority = -1; + /* + Printf(stdout, "max_possible_partials: %d col:%d\n", max_possible_partials, col); + Printf(stdout, " "); + */ + /* determine the highest rank for this nth parameter */ + for (row = 0; row < posslen; row++) { + int *element_ptr = priorities_col + row*parms_len; + int priority = *element_ptr; + if (priority > maxpriority) + maxpriority = priority; + /* Printf(stdout, "%5d ", priority); */ + } + /* Printf(stdout, "\n"); */ + /* flag all the parameters which equal the highest rank */ + for (row = 0; row < posslen; row++) { + int *element_ptr = priorities_col + row*parms_len; + int priority = *element_ptr; + *element_ptr = (priority >= maxpriority) ? 1 : 0; + } + } + } + { + int row, col; + int parms_len = ParmList_len(parms); + Iterator pi = First(possiblepartials); + Node *chosenpartials = NewList(); + if (template_debug) + Printf(stdout, " priority flags matrix:\n"); + for (row = 0; row < posslen; row++) { + int *priorities_row = priorities_matrix + row*parms_len; + int highest_count = 0; /* count of highest priority parameters */ + for (col = 0; col < parms_len; col++) { + highest_count += priorities_row[col]; + } + if (template_debug) { + Printf(stdout, " "); + for (col = 0; col < parms_len; col++) { + Printf(stdout, "%5d ", priorities_row[col]); + } + Printf(stdout, "\n"); + } + if (highest_count == parms_len) { + Append(chosenpartials, pi.item); + } + pi = Next(pi); + } + if (Len(chosenpartials) > 0) { + /* one or more best match found */ + Delete(possiblepartials); + possiblepartials = chosenpartials; + posslen = Len(possiblepartials); + } else { + /* no best match found */ + Delete(chosenpartials); + } + } + } + + if (posslen > 0) { + String *s = Getattr(Getitem(possiblepartials, 0), "templcsymname"); + n = Swig_symbol_clookup_local(s, primary_scope); + if (posslen > 1) { + int i; + if (n) { + Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, cparse_file, cparse_line, "Instantiation of template '%s' is ambiguous,\n", SwigType_namestr(tname)); + Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, Getfile(n), Getline(n), " instantiation '%s' used,\n", SwigType_namestr(Getattr(n, "name"))); + } + for (i = 1; i < posslen; i++) { + String *templcsymname = Getattr(Getitem(possiblepartials, i), "templcsymname"); + Node *ignored_node = Swig_symbol_clookup_local(templcsymname, primary_scope); + Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, Getfile(ignored_node), Getline(ignored_node), " instantiation '%s' ignored.\n", SwigType_namestr(Getattr(ignored_node, "name"))); + } + } + } + + if (!n) { + if (template_debug) { + Printf(stdout, " chosen primary template: '%s'\n", Getattr(templ, "name")); + } + n = templ; + } + } else { + if (template_debug) { + Printf(stdout, " primary template not found\n"); + } + /* Give up if primary (unspecialized) template not found as specializations will only exist if there is a primary template */ + n = 0; } - if (!n) { - n = templ; - } if (!n) { Swig_error(cparse_file, cparse_line, "Template '%s' undefined.\n", name); } else if (n) { @@ -610,12 +820,16 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) { success: Delete(tname); Delete(rname); - Delete(mpartials); + Delete(possiblepartials); if ((template_debug) && (n)) { + /* Printf(stdout, "Node: %p\n", n); Swig_print_node(n); + */ + Printf(stdout, " chosen template:'%s'\n", Getattr(n, "name")); } Delete(parms); + free(priorities_matrix); return n; } From 132376badea420005bc40ac35dd8145417f1641c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Oct 2009 18:22:16 +0000 Subject: [PATCH 204/352] Fix std::vector of const pointers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11704 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 ++ Examples/test-suite/li_std_vector_extra.i | 5 ++- Examples/test-suite/li_std_vector_ptr.i | 1 + .../python/li_std_vector_extra_runme.py | 20 ++++++++++ Lib/std/std_vector.i | 40 +++++++++++++++++++ 5 files changed, 67 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 16d5c6c28..0c8e39ed2 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.41 (in progress) ============================ +2009-10-20: wsfulton + [Python] Fix std::vector. This would previously compile, but not run correctly. + 2009-10-20: wsfulton Fixed previously fairly poor template partial specialization and explicit specialization support. Numerous bugs in this area have been fixed including: diff --git a/Examples/test-suite/li_std_vector_extra.i b/Examples/test-suite/li_std_vector_extra.i index 9c2497f7c..114de3f11 100644 --- a/Examples/test-suite/li_std_vector_extra.i +++ b/Examples/test-suite/li_std_vector_extra.i @@ -125,15 +125,16 @@ std::vector vecStr(std::vector v) { %inline %{ int *makeIntPtr(int v) { return new int(v); } + const short *makeConstShortPtr(int v) { return new short(v); } double *makeDoublePtr(double v) { return new double(v); } int extractInt(int *p) { return *p; } + short extractConstShort(const short *p) { return *p; } %} %template(pyvector) std::vector; namespace std { - %template(ConstShortVector) vector; -// %template(ConstIntVector) vector; // interferes with vector... see new testcase li_std_vector_ptr + %template(ConstShortPtrVector) vector; } %inline %{ diff --git a/Examples/test-suite/li_std_vector_ptr.i b/Examples/test-suite/li_std_vector_ptr.i index 688cbdd54..292c9d700 100644 --- a/Examples/test-suite/li_std_vector_ptr.i +++ b/Examples/test-suite/li_std_vector_ptr.i @@ -1,3 +1,4 @@ +// Bug 2359417 %module li_std_vector_ptr %include "std_vector.i" diff --git a/Examples/test-suite/python/li_std_vector_extra_runme.py b/Examples/test-suite/python/li_std_vector_extra_runme.py index 776eacfb3..8900d7298 100644 --- a/Examples/test-suite/python/li_std_vector_extra_runme.py +++ b/Examples/test-suite/python/li_std_vector_extra_runme.py @@ -154,3 +154,23 @@ if extractInt(vi[0]) != 11: if extractInt(vi[1]) != 22: raise RuntimeError +# vector const pointer checks +csp = makeConstShortPtr(111) + +error = 0 +try: + vcs = ConstShortPtrVector((csp, dp)) # check vector does not accept double * element + error = 1 +except: + pass + +if error: + raise RuntimeError + +vcs = ConstShortPtrVector((csp, makeConstShortPtr(222))) +if extractConstShort(vcs[0]) != 111: + raise RuntimeError + +if extractConstShort(vcs[1]) != 222: + raise RuntimeError + diff --git a/Lib/std/std_vector.i b/Lib/std/std_vector.i index ab1435b31..b0bb714d4 100644 --- a/Lib/std/std_vector.i +++ b/Lib/std/std_vector.i @@ -134,6 +134,46 @@ namespace std { %std_vector_methods_val(vector); }; + // *** + // const pointer specialization + // *** + template + class vector { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef const _Tp * value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type reference; + typedef value_type const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::vector), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdVectorTraits") { + namespace swig { + template <> struct traits > { + typedef value_category category; + static const char* type_name() { + return "std::vector"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector); + +#ifdef %swig_vector_methods_val + // Add swig/language extra methods + %swig_vector_methods_val(std::vector); +#endif + + %std_vector_methods_val(vector); + }; + // *** // *** // bool specialization From fd222c5e66add5f3b40c0b3e10191096be22a746 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Oct 2009 20:30:22 +0000 Subject: [PATCH 205/352] Reference the Swig_print_* family of functions in the debugging section git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11705 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/internals.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/Devel/internals.html b/Doc/Devel/internals.html index ea36f844d..d27ec12fa 100644 --- a/Doc/Devel/internals.html +++ b/Doc/Devel/internals.html @@ -1095,6 +1095,10 @@ Either
            +

            +Please also read the Debugging Functions section in SWIG Parse Tree Handling for the Swig_print_node(), Swig_print_tree() and Swig_print_tags() functions for displaying node contents. It is often easier to place a few calls to these functions in code of interest and recompile than use the debugger. +

            +
            Copyright (C) 1999-2004 SWIG Development Team. From 9062890aa6ecc9c2cc95d03063cf54b644cc0c20 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Oct 2009 20:54:19 +0000 Subject: [PATCH 206/352] update deprecated dump_tags, dump_tree, dump_module options git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11706 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Devel/tree.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/Devel/tree.html b/Doc/Devel/tree.html index 64d9d197d..43ad191f6 100644 --- a/Doc/Devel/tree.html +++ b/Doc/Devel/tree.html @@ -218,10 +218,10 @@ The following functions are used to help debug SWIG parse trees.
            Prints the tag-structure of the parse tree to standard output. node is the top-level parse tree node. prefix is a string prefix thats added to the start of each line. Normally, you would specify the empty string or NIL for prefix. -This function is called by the -dump_tags option to SWIG. +This function is called by the -debug-tags option to SWIG.
            -% swig -dump_tags -python example.i
            +% swig -debug-tags -python example.i
              . top (:1)
              . top . include (/Users/beazley/Projects/share/swig/1.3.31/swig.swg:0)
              . top . include . include (/Users/beazley/Projects/share/swig/1.3.31/swigwarnings.swg:0)
            @@ -243,7 +243,7 @@ Since many language modules include hundreds of typemaps and other information,
             
             
            Prints the contents of a parse tree node, including all children, to standard output. The output includes all attributes -and other details. The command line option -dump_tree produces output generated by this function. +and other details.

            @@ -251,8 +251,8 @@ and other details. The command line option -dump_tree produces output

            Prints the same output as Swig_print_node() except that it also processes all of the siblings of node. This can -be used to dump the entire parse tree to standard output. Use the command line option -dump_tree to get -the output of this function for a SWIG input file. +be used to dump the entire parse tree to standard output. The command line options -debug-module +and -debug-top use this function to display the parse tree for a SWIG input file.
            From bd3fddb28cd70f943fe91df3be4b2b2e843550b8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Oct 2009 22:18:43 +0000 Subject: [PATCH 207/352] Add reference to the Doc/Devel documentation. Add debugging options git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11708 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 6 ++---- Doc/Manual/Extending.html | 32 ++++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index d6feb934f..108106035 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -1599,11 +1599,9 @@
          • Prerequisites for adding a new language module to the SWIG distribution
          • Coding style guidelines
          -
        • Typemaps - +
        • Debugging Options
        • Guide to parse tree nodes +
        • Further Development Information
        diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index c56647450..111644e7f 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -66,11 +66,9 @@
      • Prerequisites for adding a new language module to the SWIG distribution
      • Coding style guidelines
      -
    24. Typemaps - +
    25. Debugging Options
    26. Guide to parse tree nodes +
    27. Further Development Information @@ -3590,11 +3588,26 @@ The generated C/C++ code should also follow this style as close as possible. How should be avoided as unlike the SWIG developers, users will never have consistent tab settings.

      -

      35.11 Typemaps

      +

      35.11 Debugging Options

      -

      35.11.1 Proxy classes

      +

      +There are various command line options which can aid debugging a SWIG interface as well as debugging the development of a language module. These are as follows: +

      +
      +-debug-classes    - Display information about the classes found in the interface
      +-debug-module <n> - Display module parse tree at stages 1-4, <n> is a csv list of stages
      +-debug-tags       - Display information about the tags found in the interface
      +-debug-template   - Display information for debugging templates
      +-debug-top <n>    - Display entire parse tree at stages 1-4, <n> is a csv list of stages
      +-debug-typedef    - Display information about the types and typedefs in the interface
      +-debug-typemap    - Display information for debugging typemaps
      +
      + +

      +The complete list of command line options for SWIG are available by running swig -help. +

      35.12 Guide to parse tree nodes

      @@ -4004,6 +4017,13 @@ extern "X" { ... } declaration. +

      35.13 Further Development Information

      + + +

      +There is further documentation available on the internals of SWIG, API documentation and debugging information. +This is shipped with SWIG in the Doc/Devel directory. +

      From f825fba4f7392a1654de8fdce894d03a80671c7d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 20 Oct 2009 23:21:28 +0000 Subject: [PATCH 208/352] fix partial specialization with many parameters git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11709 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../template_partial_specialization.i | 18 ++++++++++++++++++ Source/CParse/parser.y | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/template_partial_specialization.i b/Examples/test-suite/template_partial_specialization.i index e59ae7e5a..76bfa00fc 100644 --- a/Examples/test-suite/template_partial_specialization.i +++ b/Examples/test-suite/template_partial_specialization.i @@ -91,6 +91,24 @@ namespace Two { %template(E1_) Two::TwoParm; %template(E2_) Two::TwoParm; + +// Many template parameters +%inline %{ +template struct FiveParm { void a() {} }; +template struct FiveParm { void b() {} }; +%} + +%template(FiveParm1) FiveParm; + +%inline %{ +template struct ThreeParm; +template struct ThreeParm { void a1() {} }; +template struct ThreeParm { void a2() {} }; +template struct ThreeParm { void a3() {} }; +%} + +%template(ThreeParmInt) ThreeParm; + #if 0 // TODO fix: %inline %{ diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 29aff3d10..eeda3b0ea 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3791,7 +3791,7 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_para Parm *newp = NewParm(ttr, 0); if (partialparms) - set_nextSibling(partialparms, newp); + set_nextSibling(parm_current, newp); else partialparms = newp; parm_current = newp; From 678abc58fb3e89b6f94230db3470881bd7e1cf3d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Oct 2009 05:41:33 +0000 Subject: [PATCH 209/352] Fix seg fault when using a named template instantiation using %template(name) within a class git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11711 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 ++++ Doc/Manual/Warnings.html | 2 ++ Examples/test-suite/common.mk | 1 + .../java/template_nested_typemaps_runme.java | 27 +++++++++++++++++++ .../test-suite/template_nested_typemaps.i | 24 +++++++++++++++++ Source/Include/swigwarn.h | 1 + 6 files changed, 60 insertions(+) create mode 100644 Examples/test-suite/java/template_nested_typemaps_runme.java create mode 100644 Examples/test-suite/template_nested_typemaps.i diff --git a/CHANGES.current b/CHANGES.current index 0c8e39ed2..b8565d9cd 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.41 (in progress) ============================ +2009-10-23: wsfulton + Fix seg fault when using a named nested template instantiation using %template(name) + within a class. A warning that these are not supported is now issued plus processing + continues as if no name was given. + 2009-10-20: wsfulton [Python] Fix std::vector. This would previously compile, but not run correctly. diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 95af1ec6b..df05478a6 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -411,6 +411,8 @@ example.i(4): Syntax error in input.
    28. 320. Explicit template instantiation ignored.
    29. 321. identifier conflicts with a built-in name.
    30. 322. Redundant redeclaration of 'name'. +
    31. 323. Recursive scope inheritance of 'name'. +
    32. 324. Named nested template instantiations not supported. Processing as if no name was given to %template().
    33. 350. operator new ignored.
    34. 351. operator delete ignored.
    35. 352. operator+ ignored. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index a47f821ef..7bc5a9fa0 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -330,6 +330,7 @@ CPP_TEST_CASES += \ template_inherit_abstract \ template_int_const \ template_methods \ + template_nested_typemaps \ template_ns \ template_ns2 \ template_ns3 \ diff --git a/Examples/test-suite/java/template_nested_typemaps_runme.java b/Examples/test-suite/java/template_nested_typemaps_runme.java new file mode 100644 index 000000000..8e2354a8b --- /dev/null +++ b/Examples/test-suite/java/template_nested_typemaps_runme.java @@ -0,0 +1,27 @@ +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"); + } + } +} + diff --git a/Examples/test-suite/template_nested_typemaps.i b/Examples/test-suite/template_nested_typemaps.i new file mode 100644 index 000000000..273b4b0cf --- /dev/null +++ b/Examples/test-suite/template_nested_typemaps.i @@ -0,0 +1,24 @@ +%module template_nested_typemaps + +template struct Typemap { + %typemap(in) T { + $1 = -99; + } +}; + +%inline %{ +int globalInt1(int s) { return s; } + +template struct Breeze { + int methodInt1(int s) { return s; } +#if defined(SWIG) + %template() Typemap; +#endif + int methodInt2(int s) { return s; } // only this method should pick up the typemap within Typemap + void takeIt(T t) {} +}; + +int globalInt2(int s) { return s; } +%} + +%template(BreezeString) Breeze; diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index e8fa159af..6c54c55bd 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -84,6 +84,7 @@ #define WARN_PARSE_BUILTIN_NAME 321 #define WARN_PARSE_REDUNDANT 322 #define WARN_PARSE_REC_INHERITANCE 323 +#define WARN_PARSE_NESTED_TEMPLATE 324 #define WARN_IGNORE_OPERATOR_NEW 350 /* new */ #define WARN_IGNORE_OPERATOR_DELETE 351 /* delete */ From 16b8caa3ded254fce8955166cb1d2d36173635a8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Oct 2009 05:59:13 +0000 Subject: [PATCH 210/352] Fix seg fault when two or more %template() declarations were made within a class git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11712 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../java/template_nested_typemaps_runme.java | 10 ++++++++++ Examples/test-suite/template_nested_typemaps.i | 15 +++++++++++++++ .../template_partial_specialization.i | 4 ---- Source/CParse/parser.y | 17 ++++++++++++----- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Examples/test-suite/java/template_nested_typemaps_runme.java b/Examples/test-suite/java/template_nested_typemaps_runme.java index 8e2354a8b..3bd8aa1df 100644 --- a/Examples/test-suite/java/template_nested_typemaps_runme.java +++ b/Examples/test-suite/java/template_nested_typemaps_runme.java @@ -22,6 +22,16 @@ public class template_nested_typemaps_runme { if (template_nested_typemaps.globalInt1(v) != v) throw new RuntimeException("failed"); if (template_nested_typemaps.globalInt2(v) != v) 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"); + } } } diff --git a/Examples/test-suite/template_nested_typemaps.i b/Examples/test-suite/template_nested_typemaps.i index 273b4b0cf..8ed02eaea 100644 --- a/Examples/test-suite/template_nested_typemaps.i +++ b/Examples/test-suite/template_nested_typemaps.i @@ -1,3 +1,5 @@ +#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_TEMPLATE + %module template_nested_typemaps template struct Typemap { @@ -5,9 +7,15 @@ template struct Typemap { $1 = -99; } }; +template <> struct Typemap { + %typemap(in) short { + $1 = -77; + } +}; %inline %{ int globalInt1(int s) { return s; } +short globalShort1(short s) { return s; } template struct Breeze { int methodInt1(int s) { return s; } @@ -16,9 +24,16 @@ template struct Breeze { #endif int methodInt2(int s) { return s; } // only this method should pick up the typemap within Typemap void takeIt(T t) {} + + short methodShort1(short s) { return s; } +#if defined(SWIG) + %template(TypemapShort) Typemap; // should issue warning SWIGWARN_PARSE_NESTED_TEMPLATE +#endif + short methodShort2(short s) { return s; } // only this method should pick up the typemap within Typemap - note specialization }; int globalInt2(int s) { return s; } +short globalShort2(short s) { return s; } %} %template(BreezeString) Breeze; diff --git a/Examples/test-suite/template_partial_specialization.i b/Examples/test-suite/template_partial_specialization.i index 76bfa00fc..a81bc47a5 100644 --- a/Examples/test-suite/template_partial_specialization.i +++ b/Examples/test-suite/template_partial_specialization.i @@ -119,14 +119,10 @@ template struct ThreeParm { void a3( //} %} -#if 0 -struct AA { // crashes -#else namespace AA { // thinks X is in AA namespace %template(X2) X; }; #endif -#endif #if 0 namespace Space { diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index eeda3b0ea..4d4401572 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -535,6 +535,8 @@ static void add_symbols_copy(Node *n) { add_oldname = Getattr(n,"sym:name"); if ((add_oldname) || (Getattr(n,"sym:needs_symtab"))) { + int old_inclass = -1; + Node *old_current_class = 0; if (add_oldname) { DohIncref(add_oldname); /* Disable this, it prevents %rename to work with templates */ @@ -564,7 +566,9 @@ static void add_symbols_copy(Node *n) { Namespaceprefix = Swig_symbol_qualifiedscopename(0); } if (strcmp(cnodeType,"class") == 0) { + old_inclass = inclass; inclass = 1; + old_current_class = current_class; current_class = n; if (Strcmp(Getattr(n,"kind"),"class") == 0) { cplus_mode = CPLUS_PRIVATE; @@ -591,8 +595,8 @@ static void add_symbols_copy(Node *n) { add_oldname = 0; } if (strcmp(cnodeType,"class") == 0) { - inclass = 0; - current_class = 0; + inclass = old_inclass; + current_class = old_current_class; } } else { if (strcmp(cnodeType,"extend") == 0) { @@ -2752,7 +2756,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va } else { Setattr(templnode,"sym:typename","1"); } - if ($3) { + if ($3 && !inclass) { /* Comment this out for 1.3.28. We need to re-enable it later but first we need to @@ -2770,8 +2774,11 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va Swig_cparse_template_expand(templnode,nname,temparms,tscope); Setattr(templnode,"sym:name",nname); Delete(nname); - Setattr(templnode,"feature:onlychildren", - "typemap,typemapitem,typemapcopy,typedef,types,fragment"); + Setattr(templnode,"feature:onlychildren", "typemap,typemapitem,typemapcopy,typedef,types,fragment"); + + if ($3) { + Swig_warning(WARN_PARSE_NESTED_TEMPLATE, cparse_file, cparse_line, "Named nested template instantiations not supported. Processing as if no name was given to %%template().\n"); + } } Delattr(templnode,"templatetype"); Setattr(templnode,"template",nn); From 6fc2ce82ea774f042237fbc96098380e70c70a61 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 23 Oct 2009 06:48:38 +0000 Subject: [PATCH 211/352] Document improved template explicit specialization and partial specialization git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11713 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIGPlus.html | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index f3befa54b..f318af6a3 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -3246,22 +3246,39 @@ public:

      -SWIG should be able to handle most simple uses of partial specialization. However, it may fail -to match templates properly in more complicated cases. For example, if you have this code, +SWIG supports both template explicit specialization and partial specialization. Consider:

      -template<class T1, class T2> class Foo<T1, T2 *> { };
      +template<class T1, class T2> class Foo { };                     // (1) primary template
      +template<>                   class Foo<double *, int *> { };    // (2) explicit specialization
      +template<class T1, class T2> class Foo<T1, T2 *> { };           // (3) partial specialization
       

      -SWIG isn't able to match it properly for instantiations like Foo<int *, int *>. -This problem is not due to parsing, but due to the fact that SWIG does not currently implement all -of the C++ argument deduction rules. +SWIG is able to properly match explicit instantiations:

      +
      +
      +Foo<double *, int *>     // explicit specialization matching (2)
      +
      +
      + +

      +SWIG implements template argument deduction so that the following partial specialization examples work just like they would with a C++ compiler: +

      + +
      +
      +Foo<int *, int *>        // partial specialization matching (3)
      +Foo<int *, const int *>  // partial specialization matching (3)
      +Foo<int *, int **>       // partial specialization matching (3)
      +
      +
      +

      Member function templates are supported. The underlying principle is the same as for normal templates--SWIG can't create a wrapper unless you provide From 283fd3c7ec13662f36653480996a32d357b20482 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 24 Oct 2009 21:58:06 +0000 Subject: [PATCH 212/352] minor improvement to testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11715 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../java/template_nested_typemaps_runme.java | 2 ++ Examples/test-suite/template_nested_typemaps.i | 14 +++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/java/template_nested_typemaps_runme.java b/Examples/test-suite/java/template_nested_typemaps_runme.java index 3bd8aa1df..443faca4f 100644 --- a/Examples/test-suite/java/template_nested_typemaps_runme.java +++ b/Examples/test-suite/java/template_nested_typemaps_runme.java @@ -21,6 +21,7 @@ public class template_nested_typemaps_runme { 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"); } { @@ -31,6 +32,7 @@ public class template_nested_typemaps_runme { 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/Examples/test-suite/template_nested_typemaps.i b/Examples/test-suite/template_nested_typemaps.i index 8ed02eaea..54f5bc503 100644 --- a/Examples/test-suite/template_nested_typemaps.i +++ b/Examples/test-suite/template_nested_typemaps.i @@ -2,12 +2,14 @@ %module template_nested_typemaps +// Testing that the typemaps invoked within a class via %template are picked up by appropriate methods + template struct Typemap { %typemap(in) T { $1 = -99; } }; -template <> struct Typemap { +template <> struct Typemap { // Note explicit specialization %typemap(in) short { $1 = -77; } @@ -22,14 +24,14 @@ template struct Breeze { #if defined(SWIG) %template() Typemap; #endif - int methodInt2(int s) { return s; } // only this method should pick up the typemap within Typemap + int methodInt2(int s) { return s; } // should pick up the typemap within Typemap void takeIt(T t) {} short methodShort1(short s) { return s; } #if defined(SWIG) %template(TypemapShort) Typemap; // should issue warning SWIGWARN_PARSE_NESTED_TEMPLATE #endif - short methodShort2(short s) { return s; } // only this method should pick up the typemap within Typemap - note specialization + short methodShort2(short s) { return s; } // should pick up the typemap within Typemap }; int globalInt2(int s) { return s; } @@ -37,3 +39,9 @@ short globalShort2(short s) { return s; } %} %template(BreezeString) Breeze; + +%inline %{ +int globalInt3(int s) { return s; } // should pick up the typemap within Typemap +short globalShort3(short s) { return s; } // should pick up the typemap within Typemap +%} + From 70e8072612c4f1229b11047fca8f2141dd664ba5 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Mon, 2 Nov 2009 06:31:45 +0000 Subject: [PATCH 213/352] [Python] Fix potential memory leak in initialisation code for the generated module. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11717 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/python/pyinit.swg | 18 +++++++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b8565d9cd..692c0522c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2009-11-02: olly + [Python] Fix potential memory leak in initialisation code for the + generated module. + 2009-10-23: wsfulton Fix seg fault when using a named nested template instantiation using %template(name) within a class. A warning that these are not supported is now issued plus processing diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 058934b04..5af8d2491 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -279,15 +279,15 @@ SWIG_Python_FixMethods(PyMethodDef *methods, } } if (ci) { - size_t shift = (ci->ptype) - types; - swig_type_info *ty = types_initial[shift]; - size_t ldoc = (c - methods[i].ml_doc); - size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; - char *ndoc = (char*)malloc(ldoc + lptr + 10); - if (ndoc) { - char *buff = ndoc; - void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; - if (ptr) { + void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0; + if (ptr) { + size_t shift = (ci->ptype) - types; + swig_type_info *ty = types_initial[shift]; + size_t ldoc = (c - methods[i].ml_doc); + size_t lptr = strlen(ty->name)+2*sizeof(void*)+2; + char *ndoc = (char*)malloc(ldoc + lptr + 10); + if (ndoc) { + char *buff = ndoc; strncpy(buff, methods[i].ml_doc, ldoc); buff += ldoc; strncpy(buff, "swig_ptr: ", 10); From da1fc3ab8f30e097f17a056db023b099b383c68c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 3 Nov 2009 19:14:37 +0000 Subject: [PATCH 214/352] Fix some usage of global scope operator :: git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11719 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 22 +++++++++++++++++++ .../template_partial_specialization.i | 2 ++ Examples/test-suite/using_namespace.i | 11 ++++++++++ Examples/test-suite/valuewrapper_const.i | 6 +++++ Source/Swig/symbol.c | 8 +++++++ 5 files changed, 49 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 692c0522c..0f5f6be84 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,28 @@ Version 1.3.41 (in progress) ============================ +2009-11-03: wsfulton + Fix some usage of global scope operator, for example: + + namespace AA { /* ... */ } + using namespace ::AA; + + and bug #1816802 - SwigValueWrapper should be used :: + + struct CC { + CC(int); // no default constructor + }; + ::CC x(); + + and in template parameter specializations: + + struct S {}; + template struct X { void a() {}; }; + template <> struct X { void b() {}; }; + %template(MyTConcrete) X< ::S >; + + plus probably some other corner case usage of ::. + 2009-11-02: olly [Python] Fix potential memory leak in initialisation code for the generated module. diff --git a/Examples/test-suite/template_partial_specialization.i b/Examples/test-suite/template_partial_specialization.i index a81bc47a5..8781fbbda 100644 --- a/Examples/test-suite/template_partial_specialization.i +++ b/Examples/test-suite/template_partial_specialization.i @@ -69,6 +69,7 @@ namespace Two { template struct TwoParm { void e() {} }; template struct TwoParm { void f() {} }; template <> struct TwoParm { void g() {} }; + template <> struct TwoParm { void h() {} }; } %} @@ -90,6 +91,7 @@ namespace Two { %template(B1_) ::Two::TwoParm; %template(E1_) Two::TwoParm; %template(E2_) Two::TwoParm; +%template(H_) Two::TwoParm< ::Concrete, ::Concrete * >; // Many template parameters diff --git a/Examples/test-suite/using_namespace.i b/Examples/test-suite/using_namespace.i index 799c7cfb5..ce02e9a87 100644 --- a/Examples/test-suite/using_namespace.i +++ b/Examples/test-suite/using_namespace.i @@ -74,3 +74,14 @@ struct X { }; } + +%inline %{ +namespace SpaceMan { + typedef double SpaceManDouble; +} +using namespace ::SpaceMan; // global namespace prefix + +SpaceManDouble useSpaceMan(SpaceManDouble s) { return s; } + +%} + diff --git a/Examples/test-suite/valuewrapper_const.i b/Examples/test-suite/valuewrapper_const.i index db1c807c8..3091df30e 100644 --- a/Examples/test-suite/valuewrapper_const.i +++ b/Examples/test-suite/valuewrapper_const.i @@ -24,6 +24,12 @@ public: const B GetBconst() const { return b; } + ::B GetBGlobalQualifier() { + return b; + } + const ::B GetBconstGlobalGlobalQualifier() const { + return b; + } }; %} diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index 055af854f..3f9ce86af 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -998,6 +998,8 @@ Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) { String *nname = NewString(cname + 2); if (Swig_scopename_check(nname)) { s = symbol_lookup_qualified(nname, global_scope, 0, 0, 0); + } else { + s = symbol_lookup(nname, global_scope, 0); } Delete(nname); } else { @@ -1070,6 +1072,8 @@ Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (* String *nname = NewString(cname + 2); if (Swig_scopename_check(nname)) { s = symbol_lookup_qualified(nname, global_scope, 0, 0, checkfunc); + } else { + s = symbol_lookup(nname, global_scope, checkfunc); } Delete(nname); } else { @@ -1134,6 +1138,8 @@ Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) { String *nname = NewString(cname + 2); if (Swig_scopename_check(nname)) { s = symbol_lookup_qualified(nname, global_scope, 0, 0, 0); + } else { + s = symbol_lookup(nname, global_scope, 0); } Delete(nname); } else { @@ -1182,6 +1188,8 @@ Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n, String *nname = NewString(cname + 2); if (Swig_scopename_check(nname)) { s = symbol_lookup_qualified(nname, global_scope, 0, 0, checkfunc); + } else { + s = symbol_lookup(nname, global_scope, checkfunc); } Delete(nname); } else { From 57fff12d5f8e67be14218e3a1ed57e2291cc5c6b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 3 Nov 2009 19:52:12 +0000 Subject: [PATCH 215/352] Fix seg fault for some template parameters which have no type, just a default value git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11720 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 3 +++ Source/Swig/parms.c | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 4d4401572..b8691ab9c 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -2644,6 +2644,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va n = Swig_cparse_template_locate($5,$7,tscope); /* Patch the argument types to respect namespaces */ +Printf(stdout, " p before patching: %s\n", ParmList_str_defaultargs($7)); p = $7; while (p) { SwigType *value = Getattr(p,"value"); @@ -2669,6 +2670,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va p = nextSibling(p); } +Printf(stdout, " p after patching: %s\n", ParmList_str_defaultargs($7)); /* Look for the template */ { @@ -2746,6 +2748,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va def_supplied = 1; } } +Printf(stdout, " p tempar patching: %s\n", ParmList_str_defaultargs(temparms)); templnode = copy_node(nn); /* We need to set the node name based on name used to instantiate */ diff --git a/Source/Swig/parms.c b/Source/Swig/parms.c index 9b58f5fcb..6b0863ee4 100644 --- a/Source/Swig/parms.c +++ b/Source/Swig/parms.c @@ -114,6 +114,14 @@ int ParmList_len(ParmList *p) { return i; } +/* --------------------------------------------------------------------- + * get_empty_type() + * ---------------------------------------------------------------------- */ + +static SwigType *get_empty_type() { + return NewStringEmpty(); +} + /* --------------------------------------------------------------------- * ParmList_str() * @@ -123,7 +131,8 @@ int ParmList_len(ParmList *p) { String *ParmList_str(ParmList *p) { String *out = NewStringEmpty(); while (p) { - String *pstr = SwigType_str(Getattr(p, "type"), Getattr(p, "name")); + String *type = Getattr(p, "type"); + String *pstr = SwigType_str(type ? type : get_empty_type(), Getattr(p, "name")); Append(out, pstr); p = nextSibling(p); if (p) { @@ -144,7 +153,8 @@ String *ParmList_str_defaultargs(ParmList *p) { String *out = NewStringEmpty(); while (p) { String *value = Getattr(p, "value"); - String *pstr = SwigType_str(Getattr(p, "type"), Getattr(p, "name")); + String *type = Getattr(p, "type"); + String *pstr = SwigType_str(type ? type : get_empty_type(), Getattr(p, "name")); Append(out, pstr); if (value) { Printf(out, "=%s", value); @@ -167,7 +177,8 @@ String *ParmList_str_defaultargs(ParmList *p) { String *ParmList_protostr(ParmList *p) { String *out = NewStringEmpty(); while (p) { - String *pstr = SwigType_str(Getattr(p, "type"), 0); + String *type = Getattr(p, "type"); + String *pstr = SwigType_str(type ? type : get_empty_type(), 0); Append(out, pstr); p = nextSibling(p); if (p) { From dbe46033ee68af08508f84ddb08ba264cc8878ea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 3 Nov 2009 19:57:35 +0000 Subject: [PATCH 216/352] remove debug in last commit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11721 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index b8691ab9c..4d4401572 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -2644,7 +2644,6 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va n = Swig_cparse_template_locate($5,$7,tscope); /* Patch the argument types to respect namespaces */ -Printf(stdout, " p before patching: %s\n", ParmList_str_defaultargs($7)); p = $7; while (p) { SwigType *value = Getattr(p,"value"); @@ -2670,7 +2669,6 @@ Printf(stdout, " p before patching: %s\n", ParmList_str_defaultargs($7)); p = nextSibling(p); } -Printf(stdout, " p after patching: %s\n", ParmList_str_defaultargs($7)); /* Look for the template */ { @@ -2748,7 +2746,6 @@ Printf(stdout, " p after patching: %s\n", ParmList_str_defaultargs($7)); def_supplied = 1; } } -Printf(stdout, " p tempar patching: %s\n", ParmList_str_defaultargs(temparms)); templnode = copy_node(nn); /* We need to set the node name based on name used to instantiate */ From e351dfceaf5b1869fcda492c427149577056e1fe Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Wed, 4 Nov 2009 03:48:17 +0000 Subject: [PATCH 217/352] first pass at making fcompact work with R git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11722 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/r/rtype.swg | 16 ++++++++-------- Source/Modules/r.cxx | 34 +++++++++++++++++----------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg index d388d1eae..04441c03f 100644 --- a/Lib/r/rtype.swg +++ b/Lib/r/rtype.swg @@ -100,30 +100,30 @@ long *, long &, long[ANY] - "$input = as.integer($input) "; + "$input = as.integer($input); "; %typemap(scoercein) char *, string, std::string, string &, std::string & -%{ $input = as($input, "character") %} +%{ $input = as($input, "character"); %} %typemap(scoerceout) enum SWIGTYPE - %{ $result = enumFromInteger($result, "$R_class") %} + %{ $result = enumFromInteger($result, "$R_class"); %} %typemap(scoerceout) enum SWIGTYPE & - %{ $result = enumFromInteger($result, "$R_class") %} + %{ $result = enumFromInteger($result, "$R_class"); %} %typemap(scoerceout) enum SWIGTYPE * - %{ $result = enumToInteger($result, "$R_class") %} + %{ $result = enumToInteger($result, "$R_class"); %} %typemap(scoerceout) SWIGTYPE - %{ class($result) <- "$&R_class" %} + %{ class($result) <- "$&R_class"; %} %typemap(scoerceout) SWIGTYPE & - %{ class($result) <- "$R_class" %} + %{ class($result) <- "$R_class"; %} %typemap(scoerceout) SWIGTYPE * - %{ class($result) <- "$R_class" %} + %{ class($result) <- "$R_class"; %} /* Override the SWIGTYPE * above. */ %typemap(scoerceout) char, diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index c48e2e266..e142c3bee 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1101,7 +1101,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, Delete(pitem); } Delete(itemList); - Printf(f->code, ")\n"); + Printf(f->code, ");\n"); if (!isSet && varaccessor > 0) { Printf(f->code, "%svaccessors = c(", tab8); @@ -1117,7 +1117,7 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, Printf(f->code, "'%s'%s", item, vcount < varaccessor ? ", " : ""); } } - Printf(f->code, ")\n"); + Printf(f->code, ");\n"); } @@ -1129,24 +1129,24 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, "stop(\"No ", (isSet ? "modifiable" : "accessible"), " field named \", name, \" in ", className, ": fields are \", paste(names(accessorFuns), sep = \", \")", ")", "\n}\n", NIL); */ - Printv(f->code, tab8, - "idx = pmatch(name, names(accessorFuns))\n", + Printv(f->code, ";", tab8, + "idx = pmatch(name, names(accessorFuns));\n", tab8, "if(is.na(idx)) \n", tab8, tab4, NIL); - Printf(f->code, "return(callNextMethod(x, name%s))\n", + Printf(f->code, "return(callNextMethod(x, name%s));\n", isSet ? ", value" : ""); - Printv(f->code, tab8, "f = accessorFuns[[idx]]\n", NIL); + Printv(f->code, tab8, "f = accessorFuns[[idx]];\n", NIL); if(isSet) { - Printv(f->code, tab8, "f(x, value)\n", NIL); - Printv(f->code, tab8, "x\n", NIL); // make certain to return the S value. + Printv(f->code, tab8, "f(x, value);\n", NIL); + Printv(f->code, tab8, "x;\n", NIL); // make certain to return the S value. } else { - Printv(f->code, tab8, "formals(f)[[1]] = x\n", NIL); + Printv(f->code, tab8, "formals(f)[[1]] = x;\n", NIL); if (varaccessor) { Printv(f->code, tab8, - "if (is.na(match(name, vaccessors))) f else f(x)\n", NIL); + "if (is.na(match(name, vaccessors))) f else f(x);\n", NIL); } else { - Printv(f->code, tab8, "f\n", NIL); + Printv(f->code, tab8, "f;\n", NIL); } } Printf(f->code, "}\n"); @@ -1157,15 +1157,15 @@ int R::OutputMemberReferenceMethod(String *className, int isSet, isSet ? "<-" : "", getRClassName(className)); Wrapper_print(f, out); - Printf(out, ")\n"); + Printf(out, ");\n"); if(isSet) { Printf(out, "setMethod('[[<-', c('_p%s', 'character'),", getRClassName(className)); - Insert(f->code, 2, "name = i\n"); + Insert(f->code, 2, "name = i;\n"); Printf(attr->code, "%s", f->code); Wrapper_print(attr, out); - Printf(out, ")\n"); + Printf(out, ");\n"); } DelWrapper(attr); @@ -2090,10 +2090,10 @@ int R::functionWrapper(Node *n) { } - Printv(sfun->code, (Len(tm) ? "ans = " : ""), ".Call('", wname, - "', ", sargs, "PACKAGE='", Rpackage, "')\n", NIL); + Printv(sfun->code, ";", (Len(tm) ? "ans = " : ""), ".Call('", wname, + "', ", sargs, "PACKAGE='", Rpackage, "');\n", NIL); if(Len(tm)) - Printf(sfun->code, "%s\n\nans\n", tm); + Printf(sfun->code, "%s\n\nans;\n", tm); if (destructor) Printv(f->code, "R_ClearExternalPtr(self);\n", NIL); From 9683047b9a5f6975f2470858a311de9f885a2db7 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Wed, 4 Nov 2009 03:50:09 +0000 Subject: [PATCH 218/352] move fPIC location to be in front of -o git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11723 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 561f7cc29..3516d6f28 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1124,7 +1124,7 @@ RRSRC = $(INTERFACE:.i=.R) r: $(SRCS) $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) - +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o -fPIC $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) + +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -fPIC -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) r_cpp: $(CXXSRCS) $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) From 64d1b6f0c650ac7a84e182cee4cc965271131f76 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 4 Nov 2009 22:49:39 +0000 Subject: [PATCH 219/352] Add -debug-symtabs and -debug-qsymtabs options for debugging symbol tables git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11724 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 +++++ Doc/Manual/Extending.html | 2 ++ Source/CParse/parser.y | 14 +++------- Source/Modules/main.cxx | 18 +++++++++++++ Source/Swig/swig.h | 3 +++ Source/Swig/symbol.c | 56 +++++++++++++++++++++++++++------------ 6 files changed, 72 insertions(+), 27 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 0f5f6be84..b577367db 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.41 (in progress) ============================ +2009-11-04: wsfulton + Add new debug options: + -debug-symtabs - Display symbol tables information + -debug-qsymtabs - Display symbol tables summary information using fully + qualified names + 2009-11-03: wsfulton Fix some usage of global scope operator, for example: diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 111644e7f..11578db97 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -3598,6 +3598,8 @@ There are various command line options which can aid debugging a SWIG interface

       -debug-classes    - Display information about the classes found in the interface
       -debug-module <n> - Display module parse tree at stages 1-4, <n> is a csv list of stages
      +-debug-symtabs    - Display symbol tables information
      +-debug-qsymtabs   - Display symbol tables summary information using fully qualified names
       -debug-tags       - Display information about the tags found in the interface
       -debug-template   - Display information for debugging templates
       -debug-top <n>    - Display entire parse tree at stages 1-4, <n> is a csv list of stages
      diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
      index 4d4401572..954b7af77 100644
      --- a/Source/CParse/parser.y
      +++ b/Source/CParse/parser.y
      @@ -817,14 +817,8 @@ static List *make_inherit_list(String *clsname, List *names) {
       
       /* If the class name is qualified.  We need to create or lookup namespace entries */
       
      -static Symtab *get_global_scope() {
      -  Symtab *symtab = Swig_symbol_current();
      -  Node   *pn = parentNode(symtab);
      -  while (pn) {
      -    symtab = pn;
      -    pn = parentNode(symtab);
      -    if (!pn) break;
      -  }
      +static Symtab *set_scope_to_global() {
      +  Symtab *symtab = Swig_symbol_global_scope();
         Swig_symbol_setscope(symtab);
         return symtab;
       }
      @@ -869,11 +863,11 @@ static String *resolve_node_scope(String *cname) {
             String *nprefix = NewString(Char(prefix)+2);
             Delete(prefix);
             prefix= nprefix;
      -      gscope = get_global_scope();
      +      gscope = set_scope_to_global();
           }    
           if (!prefix || (Len(prefix) == 0)) {
             /* Use the global scope, but we need to add a 'global' namespace.  */
      -      if (!gscope) gscope = get_global_scope();
      +      if (!gscope) gscope = set_scope_to_global();
             /* note that this namespace is not the "unnamed" one,
       	 and we don't use Setattr(nscope,"name", ""),
       	 because the unnamed namespace is private */
      diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
      index c824db6f9..30e8eb18a 100644
      --- a/Source/Modules/main.cxx
      +++ b/Source/Modules/main.cxx
      @@ -62,6 +62,8 @@ static const char *usage1 = (const char *) "\
            -copyright      - Display copyright notices\n\
            -debug-classes  - Display information about the classes found in the interface\n\
            -debug-module - Display module parse tree at stages 1-4,  is a csv list of stages\n\
      +     -debug-symtabs  - Display symbol tables information\n\
      +     -debug-qsymtabs - Display symbol tables summary information using fully qualified names\n\
            -debug-tags     - Display information about the tags found in the interface\n\
            -debug-template - Display information for debugging templates\n\
            -debug-top   - Display entire parse tree at stages 1-4,  is a csv list of stages\n\
      @@ -162,6 +164,8 @@ static int no_cpp = 0;
       static char *outfile_name = 0;
       static char *outfile_name_h = 0;
       static int tm_debug = 0;
      +static int dump_symtabs = 0;
      +static int dump_qsymtabs = 0;
       static int dump_tags = 0;
       static int dump_module = 0;
       static int dump_top = 0;
      @@ -716,6 +720,12 @@ void SWIG_getoptions(int argc, char *argv[]) {
             } else if (strncmp(argv[i], "-w", 2) == 0) {
       	Swig_mark_arg(i);
       	Swig_warnfilter(argv[i] + 2, 1);
      +      } else if (strcmp(argv[i], "-debug-symtabs") == 0) {
      +	dump_symtabs = 1;
      +	Swig_mark_arg(i);
      +      } else if (strcmp(argv[i], "-debug-qsymtabs") == 0) {
      +	dump_qsymtabs = 1;
      +	Swig_mark_arg(i);
             } else if ((strcmp(argv[i], "-debug-tags") == 0) || (strcmp(argv[i], "-dump_tags") == 0)) {
       	dump_tags = 1;
       	Swig_mark_arg(i);
      @@ -1145,6 +1155,14 @@ int SWIG_main(int argc, char *argv[], Language *l) {
             SwigType_print_scope(0);
           }
       
      +    if (dump_symtabs) {
      +      Swig_symbol_tables_print(Swig_symbol_global_scope());
      +    }
      +
      +    if (dump_qsymtabs) {
      +      Swig_symbol_tables_summary_print();
      +    }
      +
           if (dump_tags) {
             Swig_print_tags(top, 0);
           }
      diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
      index a5f13bd77..e415493a0 100644
      --- a/Source/Swig/swig.h
      +++ b/Source/Swig/swig.h
      @@ -200,6 +200,8 @@ extern "C" {
       
       /* --- Symbol table module --- */
       
      +  extern void Swig_symbol_tables_print(Symtab *symtab);
      +  extern void Swig_symbol_tables_summary_print(void);
         extern void Swig_symbol_init(void);
         extern void Swig_symbol_setscopename(const_String_or_char_ptr name);
         extern String *Swig_symbol_getscopename(void);
      @@ -207,6 +209,7 @@ extern "C" {
         extern Symtab *Swig_symbol_newscope(void);
         extern Symtab *Swig_symbol_setscope(Symtab *);
         extern Symtab *Swig_symbol_getscope(const_String_or_char_ptr symname);
      +  extern Symtab *Swig_symbol_global_scope(void);
         extern Symtab *Swig_symbol_current(void);
         extern Symtab *Swig_symbol_popscope(void);
         extern Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *node);
      diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c
      index 3f9ce86af..a13361aa8 100644
      --- a/Source/Swig/symbol.c
      +++ b/Source/Swig/symbol.c
      @@ -175,20 +175,32 @@ static Hash *global_scope = 0;	/* Global scope */
       /* common attribute keys, to avoid calling find_key all the times */
       
       
      +/* -----------------------------------------------------------------------------
      + * Swig_symbol_tables_print()
      + *
      + * Debug display of symbol tables
      + * ----------------------------------------------------------------------------- */
       
      -#if 0
      -void Swig_symbol_dump_symtable() {
      -  Printf(stdout, "DUMPING SYMTABLE start =======================================\n");
      -  {
      -    Hash *cst = Getattr(current_symtab, "csymtab");
      -    Swig_print_tree(cst);
      -    /*
      -       Swig_print_tree(Getattr(cst, "NumSpace"));
      -     */
      -  }
      -  Printf(stdout, "DUMPING SYMTABLE end   =======================================\n");
      +void Swig_symbol_tables_print(Symtab *symtab) {
      +  if (!symtab)
      +    symtab = current_symtab;
      +
      +  Printf(stdout, "SYMBOL TABLES start  =======================================\n");
      +  Swig_print_tree(symtab);
      +  Printf(stdout, "SYMBOL TABLES finish =======================================\n");
      +}
      +
      +/* -----------------------------------------------------------------------------
      + * Swig_symbol_tables_summary_print()
      + *
      + * Debug summary display of all symbol tables by fully-qualified name 
      + * ----------------------------------------------------------------------------- */
      +
      +void Swig_symbol_tables_summary_print(void) {
      +  Printf(stdout, "SYMBOL TABLES SUMMARY start  =======================================\n");
      +  Swig_print_node(symtabs);
      +  Printf(stdout, "SYMBOL TABLES SUMMARY finish =======================================\n");
       }
      -#endif
       
       /* -----------------------------------------------------------------------------
        * Swig_symbol_init()
      @@ -196,7 +208,7 @@ void Swig_symbol_dump_symtable() {
        * Create a new symbol table object
        * ----------------------------------------------------------------------------- */
       
      -void Swig_symbol_init() {
      +void Swig_symbol_init(void) {
       
         current = NewHash();
         current_symtab = NewHash();
      @@ -240,7 +252,7 @@ void Swig_symbol_setscopename(const_String_or_char_ptr name) {
        * Get the C scopename of the current symbol table
        * ----------------------------------------------------------------------------- */
       
      -String *Swig_symbol_getscopename() {
      +String *Swig_symbol_getscopename(void) {
         return Getattr(current_symtab, "name");
       }
       
      @@ -295,7 +307,7 @@ String *Swig_symbol_qualifiedscopename(Symtab *symtab) {
        * Create a new scope.  Returns the newly created scope.
        * ----------------------------------------------------------------------------- */
       
      -Symtab *Swig_symbol_newscope() {
      +Symtab *Swig_symbol_newscope(void) {
         Hash *n;
         Hash *hsyms, *h;
       
      @@ -346,7 +358,7 @@ Symtab *Swig_symbol_setscope(Symtab *sym) {
        * scope to the parent scope.
        * ----------------------------------------------------------------------------- */
       
      -Symtab *Swig_symbol_popscope() {
      +Symtab *Swig_symbol_popscope(void) {
         Hash *h = current_symtab;
         current_symtab = Getattr(current_symtab, "parentNode");
         assert(current_symtab);
      @@ -357,13 +369,23 @@ Symtab *Swig_symbol_popscope() {
         return h;
       }
       
      +/* -----------------------------------------------------------------------------
      + * Swig_symbol_global_scope()
      + *
      + * Return the symbol table for the global scope.
      + * ----------------------------------------------------------------------------- */
      +
      +Symtab *Swig_symbol_global_scope(void) {
      +  return global_scope;
      +}
      +
       /* -----------------------------------------------------------------------------
        * Swig_symbol_current()
        *
        * Return the current symbol table.
        * ----------------------------------------------------------------------------- */
       
      -Symtab *Swig_symbol_current() {
      +Symtab *Swig_symbol_current(void) {
         return current_symtab;
       }
       
      
      From deba0e9285e15396c84314bbdb18bc44d99ef30c Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sat, 7 Nov 2009 20:44:20 +0000
      Subject: [PATCH 220/352] re-organise symbol debugging options - add in
       -debug-symbols and -debug-csymbols, and remove -debug-qsymtab
      
      git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11726 626c5289-ae23-0410-ae9c-e8d60b6d4f22
      ---
       CHANGES.current           |  8 +++---
       Doc/Manual/Extending.html | 39 ++++++++++++++-------------
       Source/Modules/main.cxx   | 24 ++++++++++++-----
       Source/Swig/swig.h        |  6 +++--
       Source/Swig/symbol.c      | 56 ++++++++++++++++++++++++++++++++++++---
       5 files changed, 97 insertions(+), 36 deletions(-)
      
      diff --git a/CHANGES.current b/CHANGES.current
      index b577367db..67d9f9aa1 100644
      --- a/CHANGES.current
      +++ b/CHANGES.current
      @@ -1,11 +1,11 @@
       Version 1.3.41 (in progress)
       ============================
       
      -2009-11-04: wsfulton
      +2009-11-07: wsfulton
       	    Add new debug options:
      -             -debug-symtabs  - Display symbol tables information
      -             -debug-qsymtabs - Display symbol tables summary information using fully
      -                               qualified names
      +              -debug-symtabs    - Display symbol tables information
      +              -debug-symbols    - Display target language symbols in the symbol tables
      +              -debug-csymbols   - Display C symbols in the symbol tables
       
       2009-11-03: wsfulton
       	    Fix some usage of global scope operator, for example:
      diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html
      index 11578db97..040eb65c7 100644
      --- a/Doc/Manual/Extending.html
      +++ b/Doc/Manual/Extending.html
      @@ -2604,24 +2604,24 @@ void Language::main(int argc, char *argv[]) {
                   } else {
                     Swig_arg_error();
                   }
      -	  } else if (strcmp(argv[i],"-globals") == 0) {
      -	    if (argv[i+1]) {
      -	      global_name = NewString(argv[i+1]);
      -	      Swig_mark_arg(i);
      -	      Swig_mark_arg(i+1);
      -	      i++;
      -	    } else {
      -	      Swig_arg_error();
      -	    }
      -	  } else if ( (strcmp(argv[i],"-proxy") == 0)) {
      -	    proxy_flag = 1;
      -	    Swig_mark_arg(i);
      -	  } else if (strcmp(argv[i],"-keyword") == 0) {
      -	    use_kw = 1;
      -	    Swig_mark_arg(i);
      -	  } else if (strcmp(argv[i],"-help") == 0) {
      -	    fputs(usage,stderr);
      -	  }
      +          } else if (strcmp(argv[i],"-globals") == 0) {
      +            if (argv[i+1]) {
      +              global_name = NewString(argv[i+1]);
      +              Swig_mark_arg(i);
      +              Swig_mark_arg(i+1);
      +              i++;
      +            } else {
      +              Swig_arg_error();
      +            }
      +          } else if ( (strcmp(argv[i],"-proxy") == 0)) {
      +            proxy_flag = 1;
      +            Swig_mark_arg(i);
      +          } else if (strcmp(argv[i],"-keyword") == 0) {
      +            use_kw = 1;
      +            Swig_mark_arg(i);
      +          } else if (strcmp(argv[i],"-help") == 0) {
      +            fputs(usage,stderr);
      +          }
                 ...
             }
         }
      @@ -3599,7 +3599,8 @@ There are various command line options which can aid debugging a SWIG interface
       -debug-classes    - Display information about the classes found in the interface
       -debug-module <n> - Display module parse tree at stages 1-4, <n> is a csv list of stages
       -debug-symtabs    - Display symbol tables information
      --debug-qsymtabs   - Display symbol tables summary information using fully qualified names
      +-debug-symbols    - Display target language symbols in the symbol tables
      +-debug-csymbols   - Display C symbols in the symbol tables
       -debug-tags       - Display information about the tags found in the interface
       -debug-template   - Display information for debugging templates
       -debug-top <n>    - Display entire parse tree at stages 1-4, <n> is a csv list of stages
      diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
      index 30e8eb18a..30d12f26b 100644
      --- a/Source/Modules/main.cxx
      +++ b/Source/Modules/main.cxx
      @@ -63,7 +63,8 @@ static const char *usage1 = (const char *) "\
            -debug-classes  - Display information about the classes found in the interface\n\
            -debug-module - Display module parse tree at stages 1-4,  is a csv list of stages\n\
            -debug-symtabs  - Display symbol tables information\n\
      -     -debug-qsymtabs - Display symbol tables summary information using fully qualified names\n\
      +     -debug-symbols  - Display target language symbols in the symbol tables\n\
      +     -debug-csymbols - Display C symbols in the symbol tables\n\
            -debug-tags     - Display information about the tags found in the interface\n\
            -debug-template - Display information for debugging templates\n\
            -debug-top   - Display entire parse tree at stages 1-4,  is a csv list of stages\n\
      @@ -165,7 +166,8 @@ static char *outfile_name = 0;
       static char *outfile_name_h = 0;
       static int tm_debug = 0;
       static int dump_symtabs = 0;
      -static int dump_qsymtabs = 0;
      +static int dump_symbols = 0;
      +static int dump_csymbols = 0;
       static int dump_tags = 0;
       static int dump_module = 0;
       static int dump_top = 0;
      @@ -723,8 +725,11 @@ void SWIG_getoptions(int argc, char *argv[]) {
             } else if (strcmp(argv[i], "-debug-symtabs") == 0) {
       	dump_symtabs = 1;
       	Swig_mark_arg(i);
      -      } else if (strcmp(argv[i], "-debug-qsymtabs") == 0) {
      -	dump_qsymtabs = 1;
      +      } else if (strcmp(argv[i], "-debug-symbols") == 0) {
      +	dump_symbols = 1;
      +	Swig_mark_arg(i);
      +      } else if (strcmp(argv[i], "-debug-csymbols") == 0) {
      +	dump_csymbols = 1;
       	Swig_mark_arg(i);
             } else if ((strcmp(argv[i], "-debug-tags") == 0) || (strcmp(argv[i], "-dump_tags") == 0)) {
       	dump_tags = 1;
      @@ -1156,11 +1161,16 @@ int SWIG_main(int argc, char *argv[], Language *l) {
           }
       
           if (dump_symtabs) {
      -      Swig_symbol_tables_print(Swig_symbol_global_scope());
      +      Swig_symbol_print_tables(Swig_symbol_global_scope());
      +      Swig_symbol_print_tables_summary();
           }
       
      -    if (dump_qsymtabs) {
      -      Swig_symbol_tables_summary_print();
      +    if (dump_symbols) {
      +      Swig_symbol_print_symbols();
      +    }
      +
      +    if (dump_csymbols) {
      +      Swig_symbol_print_csymbols();
           }
       
           if (dump_tags) {
      diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
      index e415493a0..33f977b52 100644
      --- a/Source/Swig/swig.h
      +++ b/Source/Swig/swig.h
      @@ -200,8 +200,10 @@ extern "C" {
       
       /* --- Symbol table module --- */
       
      -  extern void Swig_symbol_tables_print(Symtab *symtab);
      -  extern void Swig_symbol_tables_summary_print(void);
      +  extern void Swig_symbol_print_tables(Symtab *symtab);
      +  extern void Swig_symbol_print_tables_summary(void);
      +  extern void Swig_symbol_print_symbols(void);
      +  extern void Swig_symbol_print_csymbols(void);
         extern void Swig_symbol_init(void);
         extern void Swig_symbol_setscopename(const_String_or_char_ptr name);
         extern String *Swig_symbol_getscopename(void);
      diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c
      index a13361aa8..ae8a274c6 100644
      --- a/Source/Swig/symbol.c
      +++ b/Source/Swig/symbol.c
      @@ -176,12 +176,12 @@ static Hash *global_scope = 0;	/* Global scope */
       
       
       /* -----------------------------------------------------------------------------
      - * Swig_symbol_tables_print()
      + * Swig_symbol_print_tables()
        *
        * Debug display of symbol tables
        * ----------------------------------------------------------------------------- */
       
      -void Swig_symbol_tables_print(Symtab *symtab) {
      +void Swig_symbol_print_tables(Symtab *symtab) {
         if (!symtab)
           symtab = current_symtab;
       
      @@ -191,17 +191,65 @@ void Swig_symbol_tables_print(Symtab *symtab) {
       }
       
       /* -----------------------------------------------------------------------------
      - * Swig_symbol_tables_summary_print()
      + * Swig_symbol_print_tables_summary()
        *
        * Debug summary display of all symbol tables by fully-qualified name 
        * ----------------------------------------------------------------------------- */
       
      -void Swig_symbol_tables_summary_print(void) {
      +void Swig_symbol_print_tables_summary(void) {
         Printf(stdout, "SYMBOL TABLES SUMMARY start  =======================================\n");
         Swig_print_node(symtabs);
         Printf(stdout, "SYMBOL TABLES SUMMARY finish =======================================\n");
       }
       
      +/* -----------------------------------------------------------------------------
      + * symbol_print_symbols()
      + * ----------------------------------------------------------------------------- */
      +
      +static void symbol_print_symbols(const char *symboltabletype) {
      +  Node *obj = symtabs;
      +  Iterator ki = First(obj);
      +  while (ki.key) {
      +    String *k = ki.key;
      +    Printf(stdout, "===================================================\n");
      +    Printf(stdout, "%s -\n", k);
      +    {
      +      Symtab *symtab = Getattr(Getattr(obj, k), symboltabletype);
      +      Iterator it = First(symtab);
      +      while (it.key) {
      +	String *symname = it.key;
      +	Printf(stdout, "  %s\n", symname);
      +	it = Next(it);
      +      }
      +    }
      +    ki = Next(ki);
      +  }
      +}
      +
      +/* -----------------------------------------------------------------------------
      + * Swig_symbol_print_symbols()
      + *
      + * Debug display of all the target language symbols
      + * ----------------------------------------------------------------------------- */
      +
      +void Swig_symbol_print_symbols(void) {
      +  Printf(stdout, "SYMBOLS start  =======================================\n");
      +  symbol_print_symbols("symtab");
      +  Printf(stdout, "SYMBOLS finish =======================================\n");
      +}
      +
      +/* -----------------------------------------------------------------------------
      + * Swig_symbol_print_csymbols()
      + *
      + * Debug display of all the C symbols
      + * ----------------------------------------------------------------------------- */
      +
      +void Swig_symbol_print_csymbols(void) {
      +  Printf(stdout, "CSYMBOLS start  =======================================\n");
      +  symbol_print_symbols("csymtab");
      +  Printf(stdout, "CSYMBOLS finish =======================================\n");
      +}
      +
       /* -----------------------------------------------------------------------------
        * Swig_symbol_init()
        *
      
      From ec6bf1ec9625f5f9cd42d619369c1cd35e65092d Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sun, 8 Nov 2009 00:14:47 +0000
      Subject: [PATCH 221/352] Fix nested template classes within a namespace
       generating uncompileable code by incorrectly adding in symbols into the
       symbol tables and not setting the scope correctly after the nested template
       was parsed
      
      git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11727 626c5289-ae23-0410-ae9c-e8d60b6d4f22
      ---
       CHANGES.current                               |   7 +-
       Examples/test-suite/common.mk                 |   1 +
       .../java/template_nested_runme.java           |  30 +
       Examples/test-suite/template_nested.i         |  91 +++
       Source/CParse/parser.y                        | 704 +++++++++---------
       5 files changed, 500 insertions(+), 333 deletions(-)
       create mode 100644 Examples/test-suite/java/template_nested_runme.java
       create mode 100644 Examples/test-suite/template_nested.i
      
      diff --git a/CHANGES.current b/CHANGES.current
      index 67d9f9aa1..8192f30b5 100644
      --- a/CHANGES.current
      +++ b/CHANGES.current
      @@ -1,6 +1,11 @@
       Version 1.3.41 (in progress)
       ============================
       
      +2009-11-07: wsfulton
      +	    Bug #1514681 - Fix nested template classes within a namespace generated uncompileable
      +            code and introduced strange side effects to other wrapper code especially code
      +            after the nested template class. Note that nested template classes are still ignored.
      +
       2009-11-07: wsfulton
       	    Add new debug options:
                     -debug-symtabs    - Display symbol tables information
      @@ -13,7 +18,7 @@ Version 1.3.41 (in progress)
                     namespace AA { /* ... */ }
                     using namespace ::AA;
       
      -            and bug #1816802 - SwigValueWrapper should be used ::
      +            and bug #1816802 - SwigValueWrapper should be used:
       
                     struct CC {
                       CC(int); // no default constructor
      diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
      index 7bc5a9fa0..473d6579d 100644
      --- a/Examples/test-suite/common.mk
      +++ b/Examples/test-suite/common.mk
      @@ -330,6 +330,7 @@ CPP_TEST_CASES += \
       	template_inherit_abstract \
       	template_int_const \
       	template_methods \
      +	template_nested \
       	template_nested_typemaps \
       	template_ns \
       	template_ns2 \
      diff --git a/Examples/test-suite/java/template_nested_runme.java b/Examples/test-suite/java/template_nested_runme.java
      new file mode 100644
      index 000000000..407821674
      --- /dev/null
      +++ b/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/Examples/test-suite/template_nested.i b/Examples/test-suite/template_nested.i
      new file mode 100644
      index 000000000..cb5eddb50
      --- /dev/null
      +++ b/Examples/test-suite/template_nested.i
      @@ -0,0 +1,91 @@
      +%module template_nested
      +
      +// Test nested templates - that is template classes and template methods within a class.
      +
      +#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS
      +
      +%inline %{
      +
      +namespace ns {
      +
      +  class NormalClass {
      +  public:
      +    NormalClass() {}
      +    ~NormalClass() {}
      +  };
      +
      +  template  struct NormalTemplate {
      +    void tmethod(T t) {}
      +  };
      +
      +  class OuterClass {
      +  public:
      +    template  struct Inner1 {
      +      template  struct SuperInner1 {
      +        void method1(U t) {}
      +      };
      +      template  struct SuperInner2 {
      +        void method1(V t) {}
      +      };
      +      template  void tmethod(W w) {}
      +      template  void tmethodAgain(X x) {}
      +      template  struct SuperBase : public SuperInner1 {
      +        void method1(Y y) {}
      +      };
      +    };
      +
      +    template  void InnerTMethod(Z z) {}
      +
      +    template  class Inner2 : public NormalTemplate {
      +    public:
      +      template  class SuperInner1 {
      +      public:
      +        SuperInner1() {}
      +        void method1(U t) {}
      +      };
      +      template  struct SuperInner2 {
      +        void method1(V t) {}
      +      };
      +      int embeddedVar;
      +      template  void tmethod(X x) {}
      +      template  struct SuperBase : public SuperInner1 {
      +        void method1(Y y) {}
      +      };
      +    };
      +    int iii;
      +  };
      +  struct ABC {
      +    ABC() {}
      +    ~ABC() {}
      +  };
      +
      +  struct TemplateFuncs {
      +    template  X templateMethod1(X x) { return x; }
      +    template  X templateMethod2(X x) { return x; }
      +  };
      +
      +  template  struct OuterTemplate {
      +    template  struct NestedInnerTemplate1 {
      +      template  void NestedInnerInnerTMethod(Z z) {}
      +      void hohum() {}
      +    };
      +    template  void NestedInnerTMethod(UU u, W w) {}
      +    template  struct NestedInnerTemplate2 {
      +      void hohum() {}
      +    };
      +    UU hohum(UU u) { return u; }
      +    struct NestedStruct {
      +      NestedStruct() {}
      +      void hohum() {}
      +    };
      +  };
      +}
      +
      +%}
      +
      +%template(T_NormalTemplateNormalClass) ns::NormalTemplate;
      +%template(T_OuterTMethodNormalClass) ns::OuterClass::InnerTMethod;
      +%template(T_TemplateFuncs1Int) ns::TemplateFuncs::templateMethod1;
      +%template(T_TemplateFuncs2Double) ns::TemplateFuncs::templateMethod2;
      +%template(T_NestedOuterTemplateDouble) ns::OuterTemplate;
      +
      diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
      index 954b7af77..1cd7dc750 100644
      --- a/Source/CParse/parser.y
      +++ b/Source/CParse/parser.y
      @@ -43,6 +43,7 @@ static Node    *module_node = 0;
       static String  *Classprefix = 0;  
       static String  *Namespaceprefix = 0;
       static int      inclass = 0;
      +static int      nested_template = 0; /* template class/function definition within a class */
       static char    *last_cpptype = 0;
       static int      inherit_list = 0;
       static Parm    *template_parameters = 0;
      @@ -272,6 +273,14 @@ static int  add_only_one = 0;
       static void add_symbols(Node *n) {
         String *decl;
         String *wrn = 0;
      +
      +  if (nested_template) {
      +    if (!(n && Equal(nodeType(n), "template"))) {
      +      return;
      +    }
      +    /* continue if template function, but not template class, declared within a class */
      +  }
      +
         if (inclass && n) {
           cparse_normalize_void(n);
         }
      @@ -3227,10 +3236,10 @@ cpp_declaration : cpp_class_decl {  $$ = $1; }
                       | cpp_catch_decl { $$ = 0; }
                       ;
       
      -cpp_class_decl  :
       
       /* A simple class/struct/union definition */
      -                storage_class cpptype idcolon inherit LBRACE {
      +cpp_class_decl  : storage_class cpptype idcolon inherit LBRACE {
      +                 if (nested_template == 0) {
                          List *bases = 0;
       		   Node *scope = 0;
       		   $$ = new_node("class");
      @@ -3344,120 +3353,128 @@ cpp_class_decl  :
       		   }
       		   class_decl[class_level++] = $$;
       		   inclass = 1;
      +		 }
                      } cpp_members RBRACE cpp_opt_declarators {
      -		 Node *p;
      -		 SwigType *ty;
      -		 Symtab *cscope = prev_symtab;
      -		 Node *am = 0;
      -		 String *scpname = 0;
      -		 $$ = class_decl[--class_level];
      -		 inclass = 0;
      -		 
      -		 /* Check for pure-abstract class */
      -		 Setattr($$,"abstract", pure_abstract($7));
      -		 
      -		 /* This bit of code merges in a previously defined %extend directive (if any) */
      -		 
      -		 if (extendhash) {
      -		   String *clsname = Swig_symbol_qualifiedscopename(0);
      -		   am = Getattr(extendhash,clsname);
      -		   if (am) {
      -		     merge_extensions($$,am);
      -		     Delattr(extendhash,clsname);
      +		 if (nested_template == 0) {
      +		   Node *p;
      +		   SwigType *ty;
      +		   Symtab *cscope = prev_symtab;
      +		   Node *am = 0;
      +		   String *scpname = 0;
      +		   $$ = class_decl[--class_level];
      +		   inclass = 0;
      +		   
      +		   /* Check for pure-abstract class */
      +		   Setattr($$,"abstract", pure_abstract($7));
      +		   
      +		   /* This bit of code merges in a previously defined %extend directive (if any) */
      +		   
      +		   if (extendhash) {
      +		     String *clsname = Swig_symbol_qualifiedscopename(0);
      +		     am = Getattr(extendhash,clsname);
      +		     if (am) {
      +		       merge_extensions($$,am);
      +		       Delattr(extendhash,clsname);
      +		     }
      +		     Delete(clsname);
       		   }
      -		   Delete(clsname);
      -		 }
      -		 if (!classes) classes = NewHash();
      -		 scpname = Swig_symbol_qualifiedscopename(0);
      -		 Setattr(classes,scpname,$$);
      -		 Delete(scpname);
      +		   if (!classes) classes = NewHash();
      +		   scpname = Swig_symbol_qualifiedscopename(0);
      +		   Setattr(classes,scpname,$$);
      +		   Delete(scpname);
       
      -		 appendChild($$,$7);
      -		 
      -		 if (am) append_previous_extension($$,am);
      +		   appendChild($$,$7);
      +		   
      +		   if (am) append_previous_extension($$,am);
       
      -		 p = $9;
      -		 if (p) {
      -		   set_nextSibling($$,p);
      -		 }
      -		 
      -		 if (cparse_cplusplus && !cparse_externc) {
      -		   ty = NewString($3);
      -		 } else {
      -		   ty = NewStringf("%s %s", $2,$3);
      -		 }
      -		 while (p) {
      -		   Setattr(p,"storage",$1);
      -		   Setattr(p,"type",ty);
      -		   p = nextSibling(p);
      -		 }
      -		 /* Dump nested classes */
      -		 {
      -		   String *name = $3;
      -		   if ($9) {
      -		     SwigType *decltype = Getattr($9,"decl");
      -		     if (Cmp($1,"typedef") == 0) {
      -		       if (!decltype || !Len(decltype)) {
      -			 String *cname;
      -			 name = Getattr($9,"name");
      -			 cname = Copy(name);
      -			 Setattr($$,"tdname",cname);
      -			 Delete(cname);
      +		   p = $9;
      +		   if (p) {
      +		     set_nextSibling($$,p);
      +		   }
      +		   
      +		   if (cparse_cplusplus && !cparse_externc) {
      +		     ty = NewString($3);
      +		   } else {
      +		     ty = NewStringf("%s %s", $2,$3);
      +		   }
      +		   while (p) {
      +		     Setattr(p,"storage",$1);
      +		     Setattr(p,"type",ty);
      +		     p = nextSibling(p);
      +		   }
      +		   /* Dump nested classes */
      +		   {
      +		     String *name = $3;
      +		     if ($9) {
      +		       SwigType *decltype = Getattr($9,"decl");
      +		       if (Cmp($1,"typedef") == 0) {
      +			 if (!decltype || !Len(decltype)) {
      +			   String *cname;
      +			   name = Getattr($9,"name");
      +			   cname = Copy(name);
      +			   Setattr($$,"tdname",cname);
      +			   Delete(cname);
       
      -			 /* Use typedef name as class name */
      -			 if (class_rename && (Strcmp(class_rename,$3) == 0)) {
      -			   Delete(class_rename);
      -			   class_rename = NewString(name);
      +			   /* Use typedef name as class name */
      +			   if (class_rename && (Strcmp(class_rename,$3) == 0)) {
      +			     Delete(class_rename);
      +			     class_rename = NewString(name);
      +			   }
      +			   if (!Getattr(classes,name)) {
      +			     Setattr(classes,name,$$);
      +			   }
      +			   Setattr($$,"decl",decltype);
       			 }
      -			 if (!Getattr(classes,name)) {
      -			   Setattr(classes,name,$$);
      -			 }
      -			 Setattr($$,"decl",decltype);
       		       }
       		     }
      +		     appendChild($$,dump_nested(Char(name)));
       		   }
      -		   appendChild($$,dump_nested(Char(name)));
      -		 }
       
      -		 if (cplus_mode != CPLUS_PUBLIC) {
      -		 /* we 'open' the class at the end, to allow %template
      -		    to add new members */
      -		   Node *pa = new_node("access");
      -		   Setattr(pa,"kind","public");
      -		   cplus_mode = CPLUS_PUBLIC;
      -		   appendChild($$,pa);
      -		   Delete(pa);
      -		 }
      +		   if (cplus_mode != CPLUS_PUBLIC) {
      +		   /* we 'open' the class at the end, to allow %template
      +		      to add new members */
      +		     Node *pa = new_node("access");
      +		     Setattr(pa,"kind","public");
      +		     cplus_mode = CPLUS_PUBLIC;
      +		     appendChild($$,pa);
      +		     Delete(pa);
      +		   }
       
      -		 Setattr($$,"symtab",Swig_symbol_popscope());
      +		   Setattr($$,"symtab",Swig_symbol_popscope());
       
      -		 Classprefix = 0;
      -		 if (nscope_inner) {
      -		   /* this is tricky */
      -		   /* we add the declaration in the original namespace */
      -		   appendChild(nscope_inner,$$);
      -		   Swig_symbol_setscope(Getattr(nscope_inner,"symtab"));
      -		   Delete(Namespaceprefix);
      -		   Namespaceprefix = Swig_symbol_qualifiedscopename(0);
      -		   add_symbols($$);
      -		   if (nscope) $$ = nscope;
      -		   /* but the variable definition in the current scope */
      +		   Classprefix = 0;
      +		   if (nscope_inner) {
      +		     /* this is tricky */
      +		     /* we add the declaration in the original namespace */
      +		     appendChild(nscope_inner,$$);
      +		     Swig_symbol_setscope(Getattr(nscope_inner,"symtab"));
      +		     Delete(Namespaceprefix);
      +		     Namespaceprefix = Swig_symbol_qualifiedscopename(0);
      +		     add_symbols($$);
      +		     if (nscope) $$ = nscope;
      +		     /* but the variable definition in the current scope */
      +		     Swig_symbol_setscope(cscope);
      +		     Delete(Namespaceprefix);
      +		     Namespaceprefix = Swig_symbol_qualifiedscopename(0);
      +		     add_symbols($9);
      +		   } else {
      +		     Delete(yyrename);
      +		     yyrename = Copy(class_rename);
      +		     Delete(Namespaceprefix);
      +		     Namespaceprefix = Swig_symbol_qualifiedscopename(0);
      +
      +		     add_symbols($$);
      +		     add_symbols($9);
      +		   }
       		   Swig_symbol_setscope(cscope);
       		   Delete(Namespaceprefix);
       		   Namespaceprefix = Swig_symbol_qualifiedscopename(0);
      -		   add_symbols($9);
       		 } else {
      -		   Delete(yyrename);
      -		   yyrename = Copy(class_rename);
      -		   Delete(Namespaceprefix);
      -		   Namespaceprefix = Swig_symbol_qualifiedscopename(0);
      -
      -		   add_symbols($$);
      -		   add_symbols($9);
      +		    $$ = new_node("class");
      +		    Setattr($$,"kind",$2);
      +		    Setattr($$,"name",NewString($3));
      +		    SetFlag($$,"nestedtemplateclass");
       		 }
      -		 Swig_symbol_setscope(cscope);
      -		 Delete(Namespaceprefix);
      -		 Namespaceprefix = Swig_symbol_qualifiedscopename(0);
       	       }
       
       /* An unnamed struct, possibly with a typedef */
      @@ -3617,253 +3634,276 @@ cpp_forward_class_decl : storage_class cpptype idcolon SEMI {
          template<...> decl
          ------------------------------------------------------------ */
       
      -cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { template_parameters = $3; } cpp_temp_possible {
      -		      String *tname = 0;
      -		      int     error = 0;
      +cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { 
      +		    template_parameters = $3; 
      +		    if (inclass)
      +		      nested_template++;
       
      -		      /* check if we get a namespace node with a class declaration, and retrieve the class */
      -		      Symtab *cscope = Swig_symbol_current();
      -		      Symtab *sti = 0;
      -		      Node *ntop = $6;
      -		      Node *ni = ntop;
      -		      SwigType *ntype = ni ? nodeType(ni) : 0;
      -		      while (ni && Strcmp(ntype,"namespace") == 0) {
      -			sti = Getattr(ni,"symtab");
      -			ni = firstChild(ni);
      -			ntype = nodeType(ni);
      -		      }
      -		      if (sti) {
      -			Swig_symbol_setscope(sti);
      -			Delete(Namespaceprefix);
      -			Namespaceprefix = Swig_symbol_qualifiedscopename(0);
      -			$6 = ni;
      -		      }
      +		  } cpp_temp_possible {
       
      -                      template_parameters = 0;
      -                      $$ = $6;
      -		      if ($$) tname = Getattr($$,"name");
      -		      
      -		      /* Check if the class is a template specialization */
      -		      if (($$) && (Strchr(tname,'<')) && (!is_operator(tname))) {
      -			/* If a specialization.  Check if defined. */
      -			Node *tempn = 0;
      -			{
      -			  String *tbase = SwigType_templateprefix(tname);
      -			  tempn = Swig_symbol_clookup_local(tbase,0);
      -			  if (!tempn || (Strcmp(nodeType(tempn),"template") != 0)) {
      -			    SWIG_WARN_NODE_BEGIN(tempn);
      -			    Swig_warning(WARN_PARSE_TEMPLATE_SP_UNDEF, Getfile($$),Getline($$),"Specialization of non-template '%s'.\n", tbase);
      -			    SWIG_WARN_NODE_END(tempn);
      -			    tempn = 0;
      -			    error = 1;
      -			  }
      -			  Delete(tbase);
      +		    /* Don't ignore templated functions declared within a class, unless the templated function is within a nested class */
      +		    if (nested_template <= 1) {
      +		      int is_nested_template_class = $6 && GetFlag($6, "nestedtemplateclass");
      +		      if (is_nested_template_class) {
      +			/* Nested template classes would probably better be ignored like ordinary nested classes using cpp_nested, but that introduces shift/reduce conflicts */
      +			if (cplus_mode == CPLUS_PUBLIC) {
      +			  Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested template %s not currently supported (%s ignored)\n", Getattr($6, "kind"), Getattr($6, "name"));
       			}
      -			Setattr($$,"specialization","1");
      -			Setattr($$,"templatetype",nodeType($$));
      -			set_nodeType($$,"template");
      -			/* Template partial specialization */
      -			if (tempn && ($3) && ($6)) {
      -			  List   *tlist;
      -			  String *targs = SwigType_templateargs(tname);
      -			  tlist = SwigType_parmlist(targs);
      -			  /*			  Printf(stdout,"targs = '%s' %s\n", targs, tlist); */
      +			Delete($6);
      +			$$ = 0;
      +		      } else {
      +			String *tname = 0;
      +			int     error = 0;
      +
      +			/* check if we get a namespace node with a class declaration, and retrieve the class */
      +			Symtab *cscope = Swig_symbol_current();
      +			Symtab *sti = 0;
      +			Node *ntop = $6;
      +			Node *ni = ntop;
      +			SwigType *ntype = ni ? nodeType(ni) : 0;
      +			while (ni && Strcmp(ntype,"namespace") == 0) {
      +			  sti = Getattr(ni,"symtab");
      +			  ni = firstChild(ni);
      +			  ntype = nodeType(ni);
      +			}
      +			if (sti) {
      +			  Swig_symbol_setscope(sti);
      +			  Delete(Namespaceprefix);
      +			  Namespaceprefix = Swig_symbol_qualifiedscopename(0);
      +			  $6 = ni;
      +			}
      +
      +			$$ = $6;
      +			if ($$) tname = Getattr($$,"name");
      +			
      +			/* Check if the class is a template specialization */
      +			if (($$) && (Strchr(tname,'<')) && (!is_operator(tname))) {
      +			  /* If a specialization.  Check if defined. */
      +			  Node *tempn = 0;
      +			  {
      +			    String *tbase = SwigType_templateprefix(tname);
      +			    tempn = Swig_symbol_clookup_local(tbase,0);
      +			    if (!tempn || (Strcmp(nodeType(tempn),"template") != 0)) {
      +			      SWIG_WARN_NODE_BEGIN(tempn);
      +			      Swig_warning(WARN_PARSE_TEMPLATE_SP_UNDEF, Getfile($$),Getline($$),"Specialization of non-template '%s'.\n", tbase);
      +			      SWIG_WARN_NODE_END(tempn);
      +			      tempn = 0;
      +			      error = 1;
      +			    }
      +			    Delete(tbase);
      +			  }
      +			  Setattr($$,"specialization","1");
      +			  Setattr($$,"templatetype",nodeType($$));
      +			  set_nodeType($$,"template");
      +			  /* Template partial specialization */
      +			  if (tempn && ($3) && ($6)) {
      +			    List   *tlist;
      +			    String *targs = SwigType_templateargs(tname);
      +			    tlist = SwigType_parmlist(targs);
      +			    /*			  Printf(stdout,"targs = '%s' %s\n", targs, tlist); */
      +			    if (!Getattr($$,"sym:weak")) {
      +			      Setattr($$,"sym:typename","1");
      +			    }
      +			    
      +			    if (Len(tlist) != ParmList_len(Getattr(tempn,"templateparms"))) {
      +			      Swig_error(Getfile($$),Getline($$),"Inconsistent argument count in template partial specialization. %d %d\n", Len(tlist), ParmList_len(Getattr(tempn,"templateparms")));
      +			      
      +			    } else {
      +
      +			    /* This code builds the argument list for the partial template
      +			       specialization.  This is a little hairy, but the idea is as
      +			       follows:
      +
      +			       $3 contains a list of arguments supplied for the template.
      +			       For example template.
      +
      +			       tlist is a list of the specialization arguments--which may be
      +			       different.  For example class.
      +
      +			       tp is a copy of the arguments in the original template definition.
      +       
      +			       The patching algorithm walks through the list of supplied
      +			       arguments ($3), finds the position in the specialization arguments
      +			       (tlist), and then patches the name in the argument list of the
      +			       original template.
      +			    */
      +
      +			    {
      +			      String *pn;
      +			      Parm *p, *p1;
      +			      int i, nargs;
      +			      Parm *tp = CopyParmList(Getattr(tempn,"templateparms"));
      +			      nargs = Len(tlist);
      +			      p = $3;
      +			      while (p) {
      +				for (i = 0; i < nargs; i++){
      +				  pn = Getattr(p,"name");
      +				  if (Strcmp(pn,SwigType_base(Getitem(tlist,i))) == 0) {
      +				    int j;
      +				    Parm *p1 = tp;
      +				    for (j = 0; j < i; j++) {
      +				      p1 = nextSibling(p1);
      +				    }
      +				    Setattr(p1,"name",pn);
      +				    Setattr(p1,"partialarg","1");
      +				  }
      +				}
      +				p = nextSibling(p);
      +			      }
      +			      p1 = tp;
      +			      i = 0;
      +			      while (p1) {
      +				if (!Getattr(p1,"partialarg")) {
      +				  Delattr(p1,"name");
      +				  Setattr(p1,"type", Getitem(tlist,i));
      +				} 
      +				i++;
      +				p1 = nextSibling(p1);
      +			      }
      +			      Setattr($$,"templateparms",tp);
      +			      Delete(tp);
      +			    }
      +  #if 0
      +			    /* Patch the parameter list */
      +			    if (tempn) {
      +			      Parm *p,*p1;
      +			      ParmList *tp = CopyParmList(Getattr(tempn,"templateparms"));
      +			      p = $3;
      +			      p1 = tp;
      +			      while (p && p1) {
      +				String *pn = Getattr(p,"name");
      +				Printf(stdout,"pn = '%s'\n", pn);
      +				if (pn) Setattr(p1,"name",pn);
      +				else Delattr(p1,"name");
      +				pn = Getattr(p,"type");
      +				if (pn) Setattr(p1,"type",pn);
      +				p = nextSibling(p);
      +				p1 = nextSibling(p1);
      +			      }
      +			      Setattr($$,"templateparms",tp);
      +			      Delete(tp);
      +			    } else {
      +			      Setattr($$,"templateparms",$3);
      +			    }
      +  #endif
      +			    Delattr($$,"specialization");
      +			    Setattr($$,"partialspecialization","1");
      +			    /* Create a specialized name for matching */
      +			    {
      +			      Parm *p = $3;
      +			      String *fname = NewString(Getattr($$,"name"));
      +			      String *ffname = 0;
      +			      ParmList *partialparms = 0;
      +
      +			      char   tmp[32];
      +			      int    i, ilen;
      +			      while (p) {
      +				String *n = Getattr(p,"name");
      +				if (!n) {
      +				  p = nextSibling(p);
      +				  continue;
      +				}
      +				ilen = Len(tlist);
      +				for (i = 0; i < ilen; i++) {
      +				  if (Strstr(Getitem(tlist,i),n)) {
      +				    sprintf(tmp,"$%d",i+1);
      +				    Replaceid(fname,n,tmp);
      +				  }
      +				}
      +				p = nextSibling(p);
      +			      }
      +			      /* Patch argument names with typedef */
      +			      {
      +				Iterator tt;
      +				Parm *parm_current = 0;
      +				List *tparms = SwigType_parmlist(fname);
      +				ffname = SwigType_templateprefix(fname);
      +				Append(ffname,"<(");
      +				for (tt = First(tparms); tt.item; ) {
      +				  SwigType *rtt = Swig_symbol_typedef_reduce(tt.item,0);
      +				  SwigType *ttr = Swig_symbol_type_qualify(rtt,0);
      +
      +				  Parm *newp = NewParm(ttr, 0);
      +				  if (partialparms)
      +				    set_nextSibling(parm_current, newp);
      +				  else
      +				    partialparms = newp;
      +				  parm_current = newp;
      +
      +				  Append(ffname,ttr);
      +				  tt = Next(tt);
      +				  if (tt.item) Putc(',',ffname);
      +				  Delete(rtt);
      +				  Delete(ttr);
      +				}
      +				Delete(tparms);
      +				Append(ffname,")>");
      +			      }
      +			      {
      +				Node *new_partial = NewHash();
      +				String *partials = Getattr(tempn,"partials");
      +				if (!partials) {
      +				  partials = NewList();
      +				  Setattr(tempn,"partials",partials);
      +				  Delete(partials);
      +				}
      +				/*			      Printf(stdout,"partial: fname = '%s', '%s'\n", fname, Swig_symbol_typedef_reduce(fname,0)); */
      +				Setattr(new_partial, "partialparms", partialparms);
      +				Setattr(new_partial, "templcsymname", ffname);
      +				Append(partials, new_partial);
      +			      }
      +			      Setattr($$,"partialargs",ffname);
      +			      Swig_symbol_cadd(ffname,$$);
      +			    }
      +			    }
      +			    Delete(tlist);
      +			    Delete(targs);
      +			  } else {
      +			    /* An explicit template specialization */
      +			    /* add default args from primary (unspecialized) template */
      +			    String *ty = Swig_symbol_template_deftype(tname,0);
      +			    String *fname = Swig_symbol_type_qualify(ty,0);
      +			    Swig_symbol_cadd(fname,$$);
      +			    Delete(ty);
      +			    Delete(fname);
      +			  }
      +			}  else if ($$) {
      +			  Setattr($$,"templatetype",nodeType($6));
      +			  set_nodeType($$,"template");
      +			  Setattr($$,"templateparms", $3);
       			  if (!Getattr($$,"sym:weak")) {
       			    Setattr($$,"sym:typename","1");
       			  }
      -			  
      -			  if (Len(tlist) != ParmList_len(Getattr(tempn,"templateparms"))) {
      -			    Swig_error(Getfile($$),Getline($$),"Inconsistent argument count in template partial specialization. %d %d\n", Len(tlist), ParmList_len(Getattr(tempn,"templateparms")));
      -			    
      -			  } else {
      -
      -			  /* This code builds the argument list for the partial template
      -                             specialization.  This is a little hairy, but the idea is as
      -                             follows:
      -
      -                             $3 contains a list of arguments supplied for the template.
      -                             For example template.
      -
      -                             tlist is a list of the specialization arguments--which may be
      -                             different.  For example class.
      -
      -                             tp is a copy of the arguments in the original template definition.
      -     
      -                             The patching algorithm walks through the list of supplied
      -                             arguments ($3), finds the position in the specialization arguments
      -                             (tlist), and then patches the name in the argument list of the
      -                             original template.
      -			  */
      -
      +			  add_symbols($$);
      +			  default_arguments($$);
      +			  /* We also place a fully parameterized version in the symbol table */
       			  {
      -			    String *pn;
      -			    Parm *p, *p1;
      -			    int i, nargs;
      -			    Parm *tp = CopyParmList(Getattr(tempn,"templateparms"));
      -			    nargs = Len(tlist);
      +			    Parm *p;
      +			    String *fname = NewStringf("%s<(", Getattr($$,"name"));
       			    p = $3;
      -			    while (p) {
      -			      for (i = 0; i < nargs; i++){
      -				pn = Getattr(p,"name");
      -				if (Strcmp(pn,SwigType_base(Getitem(tlist,i))) == 0) {
      -				  int j;
      -				  Parm *p1 = tp;
      -				  for (j = 0; j < i; j++) {
      -				    p1 = nextSibling(p1);
      -				  }
      -				  Setattr(p1,"name",pn);
      -				  Setattr(p1,"partialarg","1");
      -				}
      -			      }
      -			      p = nextSibling(p);
      -			    }
      -			    p1 = tp;
      -			    i = 0;
      -			    while (p1) {
      -			      if (!Getattr(p1,"partialarg")) {
      -				Delattr(p1,"name");
      -				Setattr(p1,"type", Getitem(tlist,i));
      -			      } 
      -			      i++;
      -			      p1 = nextSibling(p1);
      -			    }
      -			    Setattr($$,"templateparms",tp);
      -			    Delete(tp);
      -			  }
      -#if 0
      -			  /* Patch the parameter list */
      -			  if (tempn) {
      -			    Parm *p,*p1;
      -			    ParmList *tp = CopyParmList(Getattr(tempn,"templateparms"));
      -			    p = $3;
      -			    p1 = tp;
      -			    while (p && p1) {
      -			      String *pn = Getattr(p,"name");
      -			      Printf(stdout,"pn = '%s'\n", pn);
      -			      if (pn) Setattr(p1,"name",pn);
      -			      else Delattr(p1,"name");
      -			      pn = Getattr(p,"type");
      -			      if (pn) Setattr(p1,"type",pn);
      -			      p = nextSibling(p);
      -			      p1 = nextSibling(p1);
      -			    }
      -			    Setattr($$,"templateparms",tp);
      -			    Delete(tp);
      -			  } else {
      -			    Setattr($$,"templateparms",$3);
      -			  }
      -#endif
      -			  Delattr($$,"specialization");
      -			  Setattr($$,"partialspecialization","1");
      -			  /* Create a specialized name for matching */
      -			  {
      -			    Parm *p = $3;
      -			    String *fname = NewString(Getattr($$,"name"));
      -			    String *ffname = 0;
      -			    ParmList *partialparms = 0;
      -
      -			    char   tmp[32];
      -			    int    i, ilen;
       			    while (p) {
       			      String *n = Getattr(p,"name");
      -			      if (!n) {
      -				p = nextSibling(p);
      -				continue;
      -			      }
      -			      ilen = Len(tlist);
      -			      for (i = 0; i < ilen; i++) {
      -				if (Strstr(Getitem(tlist,i),n)) {
      -				  sprintf(tmp,"$%d",i+1);
      -				  Replaceid(fname,n,tmp);
      -				}
      -			      }
      +			      if (!n) n = Getattr(p,"type");
      +			      Append(fname,n);
       			      p = nextSibling(p);
      +			      if (p) Putc(',',fname);
       			    }
      -			    /* Patch argument names with typedef */
      -			    {
      -			      Iterator tt;
      -			      Parm *parm_current = 0;
      -			      List *tparms = SwigType_parmlist(fname);
      -			      ffname = SwigType_templateprefix(fname);
      -			      Append(ffname,"<(");
      -			      for (tt = First(tparms); tt.item; ) {
      -				SwigType *rtt = Swig_symbol_typedef_reduce(tt.item,0);
      -				SwigType *ttr = Swig_symbol_type_qualify(rtt,0);
      -
      -				Parm *newp = NewParm(ttr, 0);
      -				if (partialparms)
      -				  set_nextSibling(parm_current, newp);
      -				else
      -				  partialparms = newp;
      -				parm_current = newp;
      -
      -				Append(ffname,ttr);
      -				tt = Next(tt);
      -				if (tt.item) Putc(',',ffname);
      -				Delete(rtt);
      -				Delete(ttr);
      -			      }
      -			      Delete(tparms);
      -			      Append(ffname,")>");
      -			    }
      -			    {
      -			      Node *new_partial = NewHash();
      -			      String *partials = Getattr(tempn,"partials");
      -			      if (!partials) {
      -				partials = NewList();
      -				Setattr(tempn,"partials",partials);
      -				Delete(partials);
      -			      }
      -			      /*			      Printf(stdout,"partial: fname = '%s', '%s'\n", fname, Swig_symbol_typedef_reduce(fname,0)); */
      -			      Setattr(new_partial, "partialparms", partialparms);
      -			      Setattr(new_partial, "templcsymname", ffname);
      -			      Append(partials, new_partial);
      -			    }
      -			    Setattr($$,"partialargs",ffname);
      -			    Swig_symbol_cadd(ffname,$$);
      +			    Append(fname,")>");
      +			    Swig_symbol_cadd(fname,$$);
       			  }
      -			  }
      -			  Delete(tlist);
      -			  Delete(targs);
      -			} else {
      -			  /* An explicit template specialization */
      -			  /* add default args from primary (unspecialized) template */
      -			  String *ty = Swig_symbol_template_deftype(tname,0);
      -			  String *fname = Swig_symbol_type_qualify(ty,0);
      -			  Swig_symbol_cadd(fname,$$);
      -			  Delete(ty);
      -			  Delete(fname);
      -			}
      -		      }  else if ($$) {
      -			Setattr($$,"templatetype",nodeType($6));
      -			set_nodeType($$,"template");
      -			Setattr($$,"templateparms", $3);
      -			if (!Getattr($$,"sym:weak")) {
      -			  Setattr($$,"sym:typename","1");
      -			}
      -			add_symbols($$);
      -                        default_arguments($$);
      -			/* We also place a fully parameterized version in the symbol table */
      -			{
      -			  Parm *p;
      -			  String *fname = NewStringf("%s<(", Getattr($$,"name"));
      -			  p = $3;
      -			  while (p) {
      -			    String *n = Getattr(p,"name");
      -			    if (!n) n = Getattr(p,"type");
      -			    Append(fname,n);
      -			    p = nextSibling(p);
      -			    if (p) Putc(',',fname);
      -			  }
      -			  Append(fname,")>");
      -			  Swig_symbol_cadd(fname,$$);
       			}
      +			$$ = ntop;
      +			Swig_symbol_setscope(cscope);
      +			Delete(Namespaceprefix);
      +			Namespaceprefix = Swig_symbol_qualifiedscopename(0);
      +			if (error) $$ = 0;
       		      }
      -		      $$ = ntop;
      -		      Swig_symbol_setscope(cscope);
      -		      Delete(Namespaceprefix);
      -		      Namespaceprefix = Swig_symbol_qualifiedscopename(0);
      -		      if (error) $$ = 0;
      +		    } else {
      +		      $$ = 0;
      +		    }
      +		    template_parameters = 0;
      +		    if (inclass)
      +		      nested_template--;
                         }
                       | TEMPLATE cpptype idcolon {
       		  Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
      @@ -4377,7 +4417,6 @@ cpp_nested :   storage_class cpptype ID LBRACE { cparse_start_line = cparse_line
       		if (cplus_mode == CPLUS_PUBLIC) {
       		  if (strcmp($2,"class") == 0) {
       		    Swig_warning(WARN_PARSE_NESTED_CLASS,cparse_file, cparse_line,"Nested class not currently supported (ignored)\n");
      -		    /* Generate some code for a new class */
       		  } else if ($5.id) {
       		    /* Generate some code for a new class */
       		    Nested *n = (Nested *) malloc(sizeof(Nested));
      @@ -4409,6 +4448,7 @@ cpp_nested :   storage_class cpptype ID LBRACE { cparse_start_line = cparse_line
       		  Swig_warning(WARN_PARSE_NESTED_CLASS,cparse_file, cparse_line,"Nested class not currently supported (ignored)\n");
       		}
       	      }
      +/* This unfortunately introduces 4 shift/reduce conflicts, so instead the somewhat hacky nested_template is used for ignore nested template classes. */
       /*
                     | TEMPLATE LESSTHAN template_parms GREATERTHAN cpptype idcolon LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}');
                     } SEMI {
      
      From 9d65c100b977bd74151ac2c1c6cd03d1a27ed641 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Sun, 8 Nov 2009 01:18:45 +0000
      Subject: [PATCH 222/352] Ignored nested class/struct warnings now display the
       name of the ignored class/struct.
      
      git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11728 626c5289-ae23-0410-ae9c-e8d60b6d4f22
      ---
       CHANGES.current                      |  3 +++
       Doc/Manual/Warnings.html             |  3 +--
       Examples/test-suite/common.mk        |  1 +
       Examples/test-suite/derived_nested.i |  7 +++++
       Examples/test-suite/nested_class.i   | 40 ++++++++++++++++++++++++++++
       Source/CParse/parser.y               | 11 +++++---
       6 files changed, 59 insertions(+), 6 deletions(-)
       create mode 100644 Examples/test-suite/nested_class.i
      
      diff --git a/CHANGES.current b/CHANGES.current
      index 8192f30b5..2791a7a45 100644
      --- a/CHANGES.current
      +++ b/CHANGES.current
      @@ -1,6 +1,9 @@
       Version 1.3.41 (in progress)
       ============================
       
      +2009-11-08: wsfulton
      +	    Ignored nested class/struct warnings now display the name of the ignored class/struct.
      +
       2009-11-07: wsfulton
       	    Bug #1514681 - Fix nested template classes within a namespace generated uncompileable
                   code and introduced strange side effects to other wrapper code especially code
      diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
      index df05478a6..1150c4dc5 100644
      --- a/Doc/Manual/Warnings.html
      +++ b/Doc/Manual/Warnings.html
      @@ -399,8 +399,7 @@ example.i(4): Syntax error in input.
       
    36. 308. Namespace alias 'name' not allowed here. Assuming 'name'
    37. 309. [private | protected] inheritance ignored.
    38. 310. Template 'name' was already wrapped as 'name' (ignored) -
    39. 311. Template partial specialization not supported. -
    40. 312. Nested classes not currently supported (ignored). +
    41. 312. Nested class not currently supported (name ignored).
    42. 313. Unrecognized extern type "name" (ignored).
    43. 314. 'identifier' is a lang keyword.
    44. 315. Nothing known about 'identifier'. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 473d6579d..cf9faaad9 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -242,6 +242,7 @@ CPP_TEST_CASES += \ namespace_typemap \ namespace_virtual_method \ naturalvar \ + nested_class \ nested_comment \ newobject1 \ null_pointer \ diff --git a/Examples/test-suite/derived_nested.i b/Examples/test-suite/derived_nested.i index 2e9ace304..babcac0aa 100644 --- a/Examples/test-suite/derived_nested.i +++ b/Examples/test-suite/derived_nested.i @@ -3,6 +3,8 @@ This was reported in bug #909389 */ %module derived_nested +#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS + %inline %{ class A { int x; }; @@ -11,5 +13,10 @@ class B { 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; }; +}; %} diff --git a/Examples/test-suite/nested_class.i b/Examples/test-suite/nested_class.i new file mode 100644 index 000000000..139c0c4cf --- /dev/null +++ b/Examples/test-suite/nested_class.i @@ -0,0 +1,40 @@ +%module nested_class + +#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS + +%inline %{ +struct Outer { + struct Inner1 { + int x; + }; + + class Inner2 { + public: + int x; + }; + + class { + public: + int a; + }; + + struct { + int b; + }; + + union { + int c; + double d; + }; + + class Inner3 { + public: + int x; + } Inner3Name; + + struct Inner4 { + int x; + } Inner4Name; +}; + +%} diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 1cd7dc750..5eccc2df0 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -4395,7 +4395,7 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line n->next = 0; add_nested(n); } else { - Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", $2); + Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (%s ignored).\n", $2, $3); if (strcmp($2, "class") == 0) { /* For now, just treat the nested class as a forward * declaration (SF bug #909387). */ @@ -4416,7 +4416,10 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { if (strcmp($2,"class") == 0) { - Swig_warning(WARN_PARSE_NESTED_CLASS,cparse_file, cparse_line,"Nested class not currently supported (ignored)\n"); + if ($5.id) + Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested class not currently supported (%s ignored)\n", $5.id); + else + Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested class not currently supported (ignored)\n"); } else if ($5.id) { /* Generate some code for a new class */ Nested *n = (Nested *) malloc(sizeof(Nested)); @@ -4445,7 +4448,7 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line } SEMI { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { - Swig_warning(WARN_PARSE_NESTED_CLASS,cparse_file, cparse_line,"Nested class not currently supported (ignored)\n"); + Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $2, $3); } } /* This unfortunately introduces 4 shift/reduce conflicts, so instead the somewhat hacky nested_template is used for ignore nested template classes. */ @@ -4454,7 +4457,7 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line } SEMI { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { - Swig_warning(WARN_PARSE_NESTED_CLASS,cparse_file, cparse_line,"Nested class not currently supported (ignored)\n"); + Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $5, $6); } } */ From 99565a7c35a9936cac6c2b97f0861404900e969a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 8 Nov 2009 20:33:19 +0000 Subject: [PATCH 223/352] Add unions to the nested class test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11729 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/nested_class.i | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/nested_class.i b/Examples/test-suite/nested_class.i index 139c0c4cf..744519b96 100644 --- a/Examples/test-suite/nested_class.i +++ b/Examples/test-suite/nested_class.i @@ -4,15 +4,20 @@ %inline %{ struct Outer { - struct Inner1 { + struct InnerStruct1 { int x; }; - class Inner2 { + class InnerClass1 { public: int x; }; + union InnerUnion1 { + int x; + double y; + }; + class { public: int a; @@ -27,14 +32,19 @@ struct Outer { double d; }; - class Inner3 { + class InnerClass2 { public: int x; - } Inner3Name; + } InnerClass2Name; - struct Inner4 { + struct InnerStruct2 { int x; - } Inner4Name; + } InnerStruct2Name; + + union InnerUnion2 { + int x; + double y; + } InnerUnion2Name; }; %} From 9b318c45bc1e93c6e03a12ec5e6ab7b7e8326a04 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 8 Nov 2009 20:45:48 +0000 Subject: [PATCH 224/352] inner declared types are treated as forward declarations - consistency now between innner/nested unions/structs and classes - only relevant to C++ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11730 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 11 +++++++++++ Examples/test-suite/nested_class.i | 5 +++++ Examples/test-suite/nested_structs.i | 10 ---------- Source/CParse/parser.y | 22 +++++++++++----------- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 2791a7a45..9568a0c14 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,17 @@ Version 1.3.41 (in progress) ============================ +2009-11-08: wsfulton + Fix inconsistency for inner structs/unions/classes. Uncompileable code was being + generated when inner struct and union declarations were used as types within + the inner struct. The inner struct/union is now treated as a forward declaration making the + behaviour the same as an inner class. (C++ code), eg: + + struct Outer { + struct InnerStruct { int x; }; + InnerStruct* getInnerStruct(); + }; + 2009-11-08: wsfulton Ignored nested class/struct warnings now display the name of the ignored class/struct. diff --git a/Examples/test-suite/nested_class.i b/Examples/test-suite/nested_class.i index 744519b96..ce45b2981 100644 --- a/Examples/test-suite/nested_class.i +++ b/Examples/test-suite/nested_class.i @@ -45,6 +45,11 @@ struct Outer { int x; double y; } InnerUnion2Name; + + // bug #909387 - inner declared types are treated as forward declarations + InnerStruct1* getInnerStruct1() { return 0; } + InnerClass1* getInnerClass1() { return 0; } + InnerUnion1* getInnerUnion1() { return 0; } }; %} diff --git a/Examples/test-suite/nested_structs.i b/Examples/test-suite/nested_structs.i index 4b13ff69d..41cdd63fb 100644 --- a/Examples/test-suite/nested_structs.i +++ b/Examples/test-suite/nested_structs.i @@ -10,13 +10,3 @@ int a; %} -// bug #909387 -%inline %{ -struct foo { - struct happy; // no warning - struct sad { int x; }; // warning - happy *good(); // produces good code - sad *bad(); // produces bad code -}; -%} - diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 5eccc2df0..9c68cc647 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -4396,17 +4396,16 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line add_nested(n); } else { Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (%s ignored).\n", $2, $3); - if (strcmp($2, "class") == 0) { - /* For now, just treat the nested class as a forward - * declaration (SF bug #909387). */ - $$ = new_node("classforward"); - Setfile($$,cparse_file); - Setline($$,cparse_line); - Setattr($$,"kind",$2); - Setattr($$,"name",$3); - Setattr($$,"sym:weak", "1"); - add_symbols($$); - } + + /* For now, just treat the nested class/struct/union as a forward + * declaration (SF bug #909387). */ + $$ = new_node("classforward"); + Setfile($$,cparse_file); + Setline($$,cparse_line); + Setattr($$,"kind",$2); + Setattr($$,"name",$3); + Setattr($$,"sym:weak", "1"); + add_symbols($$); } } } @@ -4446,6 +4445,7 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line *****/ | storage_class cpptype idcolon COLON base_list LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); } SEMI { +Printf(stdout, "cpp_nested (c)\n"); $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $2, $3); From b279cd3dde30f8285d8621d5e57dab8563956bd8 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Tue, 10 Nov 2009 02:32:29 +0000 Subject: [PATCH 225/352] add std_map fix compact mode git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11731 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/r/r.swg | 8 ++++---- Lib/r/rtype.swg | 10 +++++----- Lib/r/std_map.i | 5 +++++ Lib/r/std_pair.i | 6 +++++- Source/Modules/r.cxx | 34 +++++++++++++++++----------------- 5 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 Lib/r/std_map.i diff --git a/Lib/r/r.swg b/Lib/r/r.swg index 7fd6d761f..b70d80581 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -50,7 +50,7 @@ SWIG_InitializeModule(0); %typemap(scheck) SWIGTYPE[ANY] %{ # assert(length($input) > $1_dim0) - assert(all(sapply($input, class) == "$R_class")) + assert(all(sapply($input, class) == "$R_class")); %} %typemap(out) void ""; @@ -122,14 +122,14 @@ SWIG_InitializeModule(0); /* Handling vector case to avoid warnings, although we just use the first one. */ %typemap(scheck) unsigned int %{ - assert(length($input) == 1 && $input >= 0, "All values must be non-negative") + assert(length($input) == 1 && $input >= 0, "All values must be non-negative"); %} %typemap(scheck) int, long %{ if(length($input) > 1) { - warning("using only the first element of $input") - } + warning("using only the first element of $input"); + }; %} diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg index 04441c03f..ee01d07d7 100644 --- a/Lib/r/rtype.swg +++ b/Lib/r/rtype.swg @@ -60,11 +60,11 @@ %typemap(scoercein) std::string, std::string *, std::string & %{ $input = as($input, "character"); %} %typemap(scoercein) enum SWIGTYPE - %{ $input = enumToInteger($input, "$R_class") %} + %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE & - %{ $input = enumToInteger($input, "$R_class") %} + %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) enum SWIGTYPE * - %{ $input = enumToInteger($input, "$R_class") %} + %{ $input = enumToInteger($input, "$R_class"); %} %typemap(scoercein) SWIGTYPE, SWIGTYPE *, SWIGTYPE & @@ -84,14 +84,14 @@ %typemap(scoercein) SWIGTYPE[ANY] %{ if(is.list($input)) - assert(all(sapply($input, class) == "$R_class")) + assert(all(sapply($input, class) == "$R_class")); %} /* **************************************************************** */ %typemap(scoercein) bool, bool *, bool & - "$input = as.logical($input) "; + "$input = as.logical($input);"; %typemap(scoercein) int, int *, int &, diff --git a/Lib/r/std_map.i b/Lib/r/std_map.i new file mode 100644 index 000000000..56057514c --- /dev/null +++ b/Lib/r/std_map.i @@ -0,0 +1,5 @@ +%fragment("StdMapTraits","header") +%{ +%} + +%include diff --git a/Lib/r/std_pair.i b/Lib/r/std_pair.i index 3ac795704..e9803449e 100644 --- a/Lib/r/std_pair.i +++ b/Lib/r/std_pair.i @@ -1 +1,5 @@ -%include \ No newline at end of file +%fragment("StdPairTraits","header") +%{ +%} + +%include diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index e142c3bee..41058284f 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1601,9 +1601,9 @@ void R::dispatchFunction(Node *n) { List *dispatch = Swig_overload_rank(n, true); int nfunc = Len(dispatch); Printv(f->code, - "argtypes <- mapply(class, list(...))\n", - "argv <- list(...)\n", - "argc <- length(argtypes)\n", NIL ); + "argtypes <- mapply(class, list(...));\n", + "argv <- list(...);\n", + "argc <- length(argtypes);\n", NIL ); Printf(f->code, "# dispatch functions %d\n", nfunc); int cur_args = -1; @@ -1649,16 +1649,16 @@ void R::dispatchFunction(Node *n) { } p = Getattr(p, "tmap:in:next"); } - Printf(f->code, ") { f <- %s%s }\n", sfname, overname); + Printf(f->code, ") { f <- %s%s; }\n", sfname, overname); } else { - Printf(f->code, "f <- %s%s", sfname, overname); + Printf(f->code, "f <- %s%s; ", sfname, overname); } } if (cur_args != -1) { Printv(f->code, "}", NIL); } - Printv(f->code, "\nf(...)", NIL); - Printv(f->code, "\n}", NIL); + Printv(f->code, ";\nf(...)", NIL); + Printv(f->code, ";\n}", NIL); Wrapper_print(f, sfile); Printv(sfile, "# Dispatch function\n", NIL); DelWrapper(f); @@ -1886,16 +1886,16 @@ int R::functionWrapper(Node *n) { String *snargs = NewStringf("%d", nargs); Printv(sfun->code, "if(is.function(", name, ")) {", "\n", "assert('...' %in% names(formals(", name, - ")) || length(formals(", name, ")) >= ", snargs, ")\n} ", NIL); + ")) || length(formals(", name, ")) >= ", snargs, ");\n} ", NIL); Delete(snargs); Printv(sfun->code, "else {\n", "if(is.character(", name, ")) {\n", - name, " = getNativeSymbolInfo(", name, ")", - "\n}\n", + name, " = getNativeSymbolInfo(", name, ");", + "\n};\n", "if(is(", name, ", \"NativeSymbolInfo\")) {\n", - name, " = ", name, "$address", "\n}\n", - "}\n", + name, " = ", name, "$address", ";\n}\n", + "}; \n", NIL); } else { Printf(sfun->code, "%s\n", tm); @@ -2452,11 +2452,11 @@ int R::generateCopyRoutines(Node *n) { /* The S functions to get and set the member value. */ String *elNameT = replaceInitialDash(elName); - Printf(copyToR->code, "obj@%s = value$%s\n", elNameT, elNameT); - Printf(copyToC->code, "obj$%s = value@%s\n", elNameT, elNameT); + Printf(copyToR->code, "obj@%s = value$%s;\n", elNameT, elNameT); + Printf(copyToC->code, "obj$%s = value@%s;\n", elNameT, elNameT); Delete(elNameT); } - Printf(copyToR->code, "obj\n}\n\n"); + Printf(copyToR->code, "obj;\n}\n\n"); String *rclassName = getRClassNameCopyStruct(type, 0); // without the Ref. Printf(sfile, "# Start definition of copy functions & methods for %s\n", rclassName); @@ -2466,9 +2466,9 @@ int R::generateCopyRoutines(Node *n) { Printf(sfile, "# Start definition of copy methods for %s\n", rclassName); - Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s)\n", rclassName, + Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s);\n", rclassName, mangledName); - Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s)\n\n", rclassName, + Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s);\n\n", rclassName, mangledName); Printf(sfile, "# End definition of copy methods for %s\n", rclassName); From f5e1371733a7264d7584ae869066d040ec2f4766 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Tue, 10 Nov 2009 02:38:11 +0000 Subject: [PATCH 226/352] add R changes to change list git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11732 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 9568a0c14..bfcb65514 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,7 @@ Version 1.3.41 (in progress) ============================ +2009-11-09: drjoe + Fix R for -fcompact and add std_map.i 2009-11-08: wsfulton Fix inconsistency for inner structs/unions/classes. Uncompileable code was being From a0ff0a86d046e66da8355c7e290388ea9a392463 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 11 Nov 2009 00:22:38 +0000 Subject: [PATCH 227/352] Obscure seg fault bug fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11733 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/typesys.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 2562e12f8..2022daf6a 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -1120,11 +1120,13 @@ int SwigType_typedef_using(const_String_or_char_ptr name) { /* Figure out the scope the using directive refers to */ { prefix = Swig_scopename_prefix(name); - s = SwigType_find_scope(current_scope, prefix); - if (s) { - Hash *ttab = Getattr(s, "typetab"); - if (!Getattr(ttab, base) && defined_name) { - Setattr(ttab, base, defined_name); + if (prefix) { + s = SwigType_find_scope(current_scope, prefix); + if (s) { + Hash *ttab = Getattr(s, "typetab"); + if (!Getattr(ttab, base) && defined_name) { + Setattr(ttab, base, defined_name); + } } } } From ebed6508e4cc3cee2a782fd6e15d6017c8cdcb25 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 11 Nov 2009 00:30:34 +0000 Subject: [PATCH 228/352] Nested class improvements - Fixed inconsistency in handling C++ nested classes - sometimes they were treated as forward declarations, other times as if C nested struct was parsed. Added the nestedworkaround feature for C++ nested class handling. Document improved nested class handling. Numerous C and C++ nested struct/class/union test cases added. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11734 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 24 +++- Doc/Manual/Introduction.html | 2 +- Doc/Manual/SWIG.html | 14 ++- Doc/Manual/SWIGPlus.html | 107 +++++++++++++----- Examples/test-suite/common.mk | 1 + Examples/test-suite/nested.i | 21 ++++ Examples/test-suite/nested_class.i | 60 ++++++++-- Examples/test-suite/nested_workaround.i | 38 +++++++ .../python/nested_workaround_runme.py | 13 +++ Lib/swig.swg | 5 + Source/CParse/parser.y | 94 ++++++++------- Source/Swig/symbol.c | 3 +- 12 files changed, 300 insertions(+), 82 deletions(-) create mode 100644 Examples/test-suite/nested_workaround.i create mode 100644 Examples/test-suite/python/nested_workaround_runme.py diff --git a/CHANGES.current b/CHANGES.current index bfcb65514..e03d6773a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,12 +1,30 @@ Version 1.3.41 (in progress) ============================ +2009-11-11: wsfulton + Added the nestedworkaround feature as a way to use the full functionality of a nested class + (C++ mode only). It removes the nested class from SWIG's type information so it is as if SWIG + had never parsed the nested class. The documented nested class workarounds using a global + fake class stopped working when SWIG treated the nested class as an opaque pointer, and + this feature reverts this behaviour. The documentation has been updated with details of how + to use and implement it, see the "Nested classes" section in SWIGPlus.html. + +2009-11-11: wsfulton + There were a number of C++ cases where nested classes/structs/unions were being handled + as if C code was being parsed which would oftentimes lead to uncompileable code as an + attempt was made to wrap the nested structs like it is documented for C code. Now all + nested structs/classes/unions are ignored in C++ mode, as was always documented. However, + there is an improvement as usage of nested structs/classes/unions is now always treated + as an opaque type by default, resulting in generated code that should always compile. + + *** POTENTIAL INCOMPATIBILITY *** + 2009-11-09: drjoe Fix R for -fcompact and add std_map.i 2009-11-08: wsfulton - Fix inconsistency for inner structs/unions/classes. Uncompileable code was being - generated when inner struct and union declarations were used as types within - the inner struct. The inner struct/union is now treated as a forward declaration making the + Fix inconsistency for nested structs/unions/classes. Uncompileable code was being + generated when inner struct and union declarations were used as types within the + inner struct. The inner struct/union is now treated as a forward declaration making the behaviour the same as an inner class. (C++ code), eg: struct Outer { diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index 099454cf0..df8d03fdf 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -334,7 +334,7 @@ major features include:

      Currently, the only major C++ feature not supported is nested classes--a limitation -that will be removed in a future release. +that should be removed in a future release, but has some workarounds for the moment.

      diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 8705fa182..dd1b22095 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -334,6 +334,7 @@ currently supported: For example, SWIG does not support declarations such as the following (even though this is legal C): +

       /* Non-conventional placement of storage specifier (extern) */
      @@ -347,6 +348,7 @@ void bar(Spam (Grok)(Doh));
       
       
      +

      In practice, few (if any) C programmers actually write code like @@ -360,6 +362,7 @@ is not recommended. Even though SWIG can parse C++ class declarations, it ignores declarations that are decoupled from their original class definition (the declarations are parsed, but a lot of warning messages may be generated). For example: +

      @@ -369,11 +372,12 @@ int foo::bar(int) {
       }
       
      +

    45. Certain advanced features of C++ such as nested classes -are not yet supported. Please see the section on using SWIG -with C++ for more information. +are not yet fully supported. Please see the C++ section +for more information.

      @@ -2633,6 +2637,12 @@ If you have a lot nested structure declarations, it is advisable to double-check them after running SWIG. Although, there is a good chance that they will work, you may have to modify the interface file in certain cases. +

      + +

      +Finally, note that nesting is handled differently in C++ mode, +see Nested classes. +

      5.5.8 Other things to note about structure wrapping

      diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index f318af6a3..936fd3fb1 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -4695,37 +4695,49 @@ public:

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

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

      -class Foo {
      +#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS
      +class Outer {
       public:
      -#ifndef SWIG
      -   class Bar {
      -   public:
      -     ...
      -   };
      -#endif
      -   Foo();
      -  ~Foo();
      -   ...
      +  class Inner {
      +    public:
      +      ...
      +  };
      +  Inner getInner();
      +  void useInner(const Inner& inner);
      +  ...
       };
       

      -The next workaround assumes you cannot modify the source code as was done above and it provides a solution for methods that use nested class types. -Imagine we are wrapping the Outer class which contains a nested class Inner: +Note that if Inner can be used as an opaque type, the default wrapping approach suffices. +For example, if the nested class does not need to be created from the target language, but can be obtained via a method +call, such as the getInner() method above, the returned value can then be passed around, such as passed into the +useInner() method. +

      + +

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

      @@ -4738,14 +4750,18 @@ public: int var; Inner(int v = 0) : var(v) {} }; - void method(Inner inner); + Inner getInner(); + void useInner(const Inner& inner); };
    46. -The following interface file works around SWIG nested class limitations by redefining the nested class as a global class. -A typedef for the compiler is also required in order for the generated wrappers to compile. +The following interface file works around the nested class limitations by redefining the nested class as a global class. +A typedef for the compiler and the nestedworkaround +feature flag is also required in +order for the generated wrappers to compile. This flag simply removes all the type information from SWIG, so SWIG treats +the nested class as if it had not been parsed at all.

      @@ -4753,9 +4769,6 @@ A typedef for the compiler is also required in order for the generated wrappers // File : example.i %module example -// Suppress SWIG warning -#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS - // Redefine nested class in global scope in order for SWIG to generate // a proxy class. Only SWIG parses this definition. class Inner { @@ -4764,24 +4777,62 @@ class Inner { Inner(int v = 0) : var(v) {} }; +%nestedworkaround Outer::Inner; + %{ #include "outer.h" %} %include "outer.h" +// We've fooled SWIG into thinking that Inner is a global class, so now we need +// to trick the C++ compiler into understanding this apparent global type. %{ -// SWIG thinks that Inner is a global class, so we need to trick the C++ -// compiler into understanding this so called global type. typedef Outer::Inner Inner; %} -

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

      +

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

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

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

      + +

      +Compatibility Note: SWIG-1.3.40 and earlier versions did not have the nestedworkaround feature +and the generated code resulting from parsing nested classes did not always compile. +

      + +

      6.27 A brief rant about const-correctness

      diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index cf9faaad9..93c1cc909 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -244,6 +244,7 @@ CPP_TEST_CASES += \ naturalvar \ nested_class \ nested_comment \ + nested_workaround \ newobject1 \ null_pointer \ operator_overload \ diff --git a/Examples/test-suite/nested.i b/Examples/test-suite/nested.i index 0b93be46a..004cb4814 100644 --- a/Examples/test-suite/nested.i +++ b/Examples/test-suite/nested.i @@ -12,6 +12,27 @@ 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 { diff --git a/Examples/test-suite/nested_class.i b/Examples/test-suite/nested_class.i index ce45b2981..3b964f756 100644 --- a/Examples/test-suite/nested_class.i +++ b/Examples/test-suite/nested_class.i @@ -4,52 +4,94 @@ %inline %{ struct Outer { + typedef int Integer; + /////////////////////////////////////////// struct InnerStruct1 { - int x; + Integer x; }; class InnerClass1 { public: - int x; + Integer x; }; union InnerUnion1 { - int x; + Integer x; double y; }; + /////////////////////////////////////////// class { public: - int a; + Integer a; }; struct { - int b; + Integer b; }; union { - int c; + Integer c; double d; }; + /////////////////////////////////////////// class InnerClass2 { public: - int x; + Integer x; } InnerClass2Name; struct InnerStruct2 { - int x; + Integer x; } InnerStruct2Name; union InnerUnion2 { - int x; + Integer x; double y; } InnerUnion2Name; + /////////////////////////////////////////// + class { + public: + Integer x; + } InnerClass3Name; + + struct { + Integer x; + } InnerStruct3Name; + + union { + Integer x; + double y; + } InnerUnion3Name; + + /////////////////////////////////////////// + typedef class { + public: + Integer x; + } InnerClass4; + + typedef struct { + Integer x; + } InnerStruct4; + + typedef union { + Integer x; + double y; + } InnerUnion4; + // bug #909387 - inner declared types are treated as forward declarations InnerStruct1* getInnerStruct1() { return 0; } InnerClass1* getInnerClass1() { return 0; } InnerUnion1* getInnerUnion1() { return 0; } + + InnerStruct2* getInnerStruct2() { return 0; } + InnerClass2* getInnerClass2() { return 0; } + InnerUnion2* getInnerUnion2() { return 0; } + + InnerStruct4* getInnerStruct4() { return 0; } + InnerClass4* getInnerClass4() { return 0; } + InnerUnion4* getInnerUnion4() { return 0; } }; %} diff --git a/Examples/test-suite/nested_workaround.i b/Examples/test-suite/nested_workaround.i new file mode 100644 index 000000000..9727dacee --- /dev/null +++ b/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/Examples/test-suite/python/nested_workaround_runme.py b/Examples/test-suite/python/nested_workaround_runme.py new file mode 100644 index 000000000..a8a75d370 --- /dev/null +++ b/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/Lib/swig.swg b/Lib/swig.swg index c0ecad9dd..af7fa6a30 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -136,6 +136,11 @@ #define %nocallback %feature("callback","0") #define %clearcallback %feature("callback","") +/* the %nestedworkaround directive */ +#define %nestedworkaround %feature("nestedworkaround") +#define %nonestedworkaround %feature("nestedworkaround","0") +#define %clearnestedworkaround %feature("nestedworkaround","") + /* the %fastdispatch directive */ #define %fastdispatch %feature("fastdispatch") #define %nofastdispatch %feature("fastdispatch","0") diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 9c68cc647..295f0a60c 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -4374,18 +4374,33 @@ cpp_protection_decl : PUBLIC COLON { by SWIG or this whole thing is going to puke. ---------------------------------------------------------------------- */ -/* A struct sname { } id; declaration */ +/* struct sname { } id; or struct sname { }; declaration */ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); } nested_decl SEMI { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { - if ($6.id && strcmp($2, "class") != 0) { + if (cparse_cplusplus) { + /* Treat the nested class/struct/union as a forward declaration until a proper nested class solution is implemented */ + $$ = new_node("classforward"); + Setfile($$,cparse_file); + Setline($$,cparse_line); + Setattr($$,"kind",$2); + Setattr($$,"name",$3); + Setattr($$,"sym:weak", "1"); + add_symbols($$); + + if (GetFlag($$, "feature:nestedworkaround")) { + Swig_symbol_remove($$); + $$ = 0; + } else { + Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (%s ignored).\n", $2, $3); + } + } else if ($6.id) { + /* Generate some code for a new struct */ Nested *n = (Nested *) malloc(sizeof(Nested)); n->code = NewStringEmpty(); - Printv(n->code, "typedef ", $2, " ", - Char(scanner_ccode), " $classname_", $6.id, ";\n", NIL); - + Printv(n->code, "typedef ", $2, " ", Char(scanner_ccode), " $classname_", $6.id, ";\n", NIL); n->name = Swig_copy_string($6.id); n->line = cparse_start_line; n->type = NewStringEmpty(); @@ -4394,50 +4409,53 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line SwigType_push(n->type, $6.type); n->next = 0; add_nested(n); - } else { - Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (%s ignored).\n", $2, $3); - - /* For now, just treat the nested class/struct/union as a forward - * declaration (SF bug #909387). */ - $$ = new_node("classforward"); - Setfile($$,cparse_file); - Setline($$,cparse_line); - Setattr($$,"kind",$2); - Setattr($$,"name",$3); - Setattr($$,"sym:weak", "1"); - add_symbols($$); } } } -/* A struct { } id; declaration */ + +/* struct { } id; or struct { }; declaration */ + | storage_class cpptype LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); } nested_decl SEMI { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { - if (strcmp($2,"class") == 0) { - if ($5.id) - Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested class not currently supported (%s ignored)\n", $5.id); - else - Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested class not currently supported (ignored)\n"); - } else if ($5.id) { - /* Generate some code for a new class */ - Nested *n = (Nested *) malloc(sizeof(Nested)); - n->code = NewStringEmpty(); - Printv(n->code, "typedef ", $2, " " , - Char(scanner_ccode), " $classname_", $5.id, ";\n",NIL); - n->name = Swig_copy_string($5.id); - n->line = cparse_start_line; - n->type = NewStringEmpty(); - n->kind = $2; - n->unnamed = 1; - SwigType_push(n->type,$5.type); - n->next = 0; - add_nested(n); + if ($5.id) { + if (cparse_cplusplus) { + /* Treat the nested class/struct/union as a forward declaration until a proper nested class solution is implemented */ + $$ = new_node("classforward"); + Setfile($$,cparse_file); + Setline($$,cparse_line); + Setattr($$,"kind",$2); + Setattr($$,"name",$5.id); + Setattr($$,"sym:weak", "1"); + add_symbols($$); + + if (GetFlag($$, "feature:nestedworkaround")) { + Swig_symbol_remove($$); + $$ = 0; + } else { + Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $2, $5.id); + } + } else { + /* Generate some code for a new struct */ + Nested *n = (Nested *) malloc(sizeof(Nested)); + n->code = NewStringEmpty(); + Printv(n->code, "typedef ", $2, " " , Char(scanner_ccode), " $classname_", $5.id, ";\n",NIL); + n->name = Swig_copy_string($5.id); + n->line = cparse_start_line; + n->type = NewStringEmpty(); + n->kind = $2; + n->unnamed = 1; + SwigType_push(n->type,$5.type); + n->next = 0; + add_nested(n); + } } else { Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", $2); } } } + /* A 'class name : base_list { };' declaration, always ignored */ /***** This fixes derived_nested.i, but it adds one shift/reduce. Anyway, @@ -4445,12 +4463,12 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line *****/ | storage_class cpptype idcolon COLON base_list LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); } SEMI { -Printf(stdout, "cpp_nested (c)\n"); $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $2, $3); } } + /* This unfortunately introduces 4 shift/reduce conflicts, so instead the somewhat hacky nested_template is used for ignore nested template classes. */ /* | TEMPLATE LESSTHAN template_parms GREATERTHAN cpptype idcolon LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index ae8a274c6..b5ed37c0c 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -1331,7 +1331,8 @@ void Swig_symbol_remove(Node *n) { Setattr(symtab, symname, symnext); fixovername = symnext; /* fix as symbol to remove is at head of linked list */ } else { - Delattr(symtab, symname); + if (symname) + Delattr(symtab, symname); } } if (symnext) { From aa61c716a81d95ead028b34350cf98da87d68d14 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 12 Nov 2009 19:47:04 +0000 Subject: [PATCH 229/352] Stop generating uncompileable code when using nested template classes in functions. Replace SWIGWARN_PARSE_NESTED_CLASS with SWIGWARN_PARSE_NAMED_NESTED_CLASS and SWIGWARN_PARSE_UNNAMED_NESTED_CLASS for named and unnamed nested classes respectively. Named nested class ignored warnings can now be suppressed by name using %warnfilter git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11735 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 18 ++++++++ Doc/Manual/SWIGPlus.html | 4 +- Doc/Manual/Warnings.html | 3 +- Examples/test-suite/derived_nested.i | 5 ++- Examples/test-suite/namespace_class.i | 3 +- Examples/test-suite/nested_class.i | 14 +++++- Examples/test-suite/nested_comment.i | 3 ++ Examples/test-suite/template_classes.i | 12 ------ Examples/test-suite/template_nested.i | 8 +++- Examples/test-suite/union_scope.i | 1 + Source/CParse/parser.y | 60 ++++++++++++++++++++------ Source/Include/swigwarn.h | 3 +- 12 files changed, 103 insertions(+), 31 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index e03d6773a..533c64dff 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,5 +1,23 @@ Version 1.3.41 (in progress) ============================ + +2009-11-12: wsfulton + Fix usage of nested template classes so that compileable code is generated - the nested + template class is now treated like a normal nested classes that is as an opaque type + unless the nestedworkaround feature is used. + +2009-11-12: wsfulton + Replace SWIGWARN_PARSE_NESTED_CLASS with SWIGWARN_PARSE_NAMED_NESTED_CLASS and + SWIGWARN_PARSE_UNNAMED_NESTED_CLASS for named and unnamed nested classes respectively. + + Named nested class ignored warnings can now be suppressed by name using %warnfilter, eg: + + %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner; + + but clearly unnamed nested classes cannot and the global suppression is still required, eg: + + #pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS + 2009-11-11: wsfulton Added the nestedworkaround feature as a way to use the full functionality of a nested class (C++ mode only). It removes the nested class from SWIG's type information so it is as if SWIG diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 936fd3fb1..3836c86a7 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -4714,7 +4714,8 @@ The easiest thing to do is turn a blind eye to the warning that SWIG generates,
      -#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS
      +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner;
      +
       class Outer {
       public:
         class Inner {
      @@ -4830,6 +4831,7 @@ This should just be a last resort for unusual corner cases now as SWIG can parse
       

      Compatibility Note: SWIG-1.3.40 and earlier versions did not have the nestedworkaround feature and the generated code resulting from parsing nested classes did not always compile. +Nested class warnings could also not be suppressed using %warnfilter.

      diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 1150c4dc5..15f3aa9d2 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -399,7 +399,7 @@ example.i(4): Syntax error in input.
    47. 308. Namespace alias 'name' not allowed here. Assuming 'name'
    48. 309. [private | protected] inheritance ignored.
    49. 310. Template 'name' was already wrapped as 'name' (ignored) -
    50. 312. Nested class not currently supported (name ignored). +
    51. 312. Unnamed nested class not currently supported (ignored).
    52. 313. Unrecognized extern type "name" (ignored).
    53. 314. 'identifier' is a lang keyword.
    54. 315. Nothing known about 'identifier'. @@ -412,6 +412,7 @@ example.i(4): Syntax error in input.
    55. 322. Redundant redeclaration of 'name'.
    56. 323. Recursive scope inheritance of 'name'.
    57. 324. Named nested template instantiations not supported. Processing as if no name was given to %template(). +
    58. 325. Nested class not currently supported (name ignored).
    59. 350. operator new ignored.
    60. 351. operator delete ignored.
    61. 352. operator+ ignored. diff --git a/Examples/test-suite/derived_nested.i b/Examples/test-suite/derived_nested.i index babcac0aa..9a7cfce07 100644 --- a/Examples/test-suite/derived_nested.i +++ b/Examples/test-suite/derived_nested.i @@ -3,7 +3,9 @@ This was reported in bug #909389 */ %module derived_nested -#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::CC; +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::DD; +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::EE; %inline %{ @@ -17,6 +19,7 @@ struct BB { class CC { int y; }; class DD : public A { int z; }; struct EE : public A { int z; }; + void useEE(const EE& e) {} }; %} diff --git a/Examples/test-suite/namespace_class.i b/Examples/test-suite/namespace_class.i index 5e9545ce6..7dc9139cd 100644 --- a/Examples/test-suite/namespace_class.i +++ b/Examples/test-suite/namespace_class.i @@ -1,5 +1,7 @@ %module namespace_class +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Ala::Ola; + %inline %{ template void foobar(T t) {} namespace test { @@ -210,7 +212,6 @@ namespace a %} -#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS // %copyctor doesn't work with nested class workaround %nocopyctor; diff --git a/Examples/test-suite/nested_class.i b/Examples/test-suite/nested_class.i index 3b964f756..cccebb136 100644 --- a/Examples/test-suite/nested_class.i +++ b/Examples/test-suite/nested_class.i @@ -1,6 +1,18 @@ %module nested_class -#pragma SWIG nowarn=SWIGWARN_PARSE_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::InnerClass3Name; +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct3Name; +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion3Name; +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass4; +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct4; +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion4; %inline %{ struct Outer { diff --git a/Examples/test-suite/nested_comment.i b/Examples/test-suite/nested_comment.i index a9948eb0f..c246b8dab 100644 --- a/Examples/test-suite/nested_comment.i +++ b/Examples/test-suite/nested_comment.i @@ -1,5 +1,8 @@ %module nested_comment +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) s1::n; +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) a::d; + // this example shows a problem with 'dump_nested' (parser.y). // bug #949654 diff --git a/Examples/test-suite/template_classes.i b/Examples/test-suite/template_classes.i index a05eb9b58..ebe13bd9f 100644 --- a/Examples/test-suite/template_classes.i +++ b/Examples/test-suite/template_classes.i @@ -3,12 +3,6 @@ %module template_classes - -#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS - -%{ -%} - %inline %{ template @@ -27,21 +21,16 @@ public: private: Point point; - template struct pair2nd_eq { }; - - - struct Foo : Point { }; Foo foo; - }; %} @@ -49,4 +38,3 @@ private: %template(PointInt) Point; %template(RectangleInt) RectangleTest; - diff --git a/Examples/test-suite/template_nested.i b/Examples/test-suite/template_nested.i index cb5eddb50..86b9230ae 100644 --- a/Examples/test-suite/template_nested.i +++ b/Examples/test-suite/template_nested.i @@ -2,7 +2,11 @@ // Test nested templates - that is template classes and template methods within a class. -#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_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::NestedStruct; %inline %{ @@ -33,6 +37,7 @@ namespace ns { void method1(Y y) {} }; }; + Inner1 useInner1(const Inner1& inner) { return inner; } template void InnerTMethod(Z z) {} @@ -52,6 +57,7 @@ namespace ns { void method1(Y y) {} }; }; + Inner2 useInner2(const Inner2& inner) { return inner; } int iii; }; struct ABC { diff --git a/Examples/test-suite/union_scope.i b/Examples/test-suite/union_scope.i index 67093eff6..a41b30406 100644 --- a/Examples/test-suite/union_scope.i +++ b/Examples/test-suite/union_scope.i @@ -2,6 +2,7 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) nRState; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) nRState_rstate; // Ruby, wrong class name +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) nRState::rstate; %inline %{ class nRState { diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 295f0a60c..f310d489b 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3645,12 +3645,30 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { if (nested_template <= 1) { int is_nested_template_class = $6 && GetFlag($6, "nestedtemplateclass"); if (is_nested_template_class) { + $$ = 0; /* Nested template classes would probably better be ignored like ordinary nested classes using cpp_nested, but that introduces shift/reduce conflicts */ if (cplus_mode == CPLUS_PUBLIC) { - Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested template %s not currently supported (%s ignored)\n", Getattr($6, "kind"), Getattr($6, "name")); + /* Treat the nested class/struct/union as a forward declaration until a proper nested class solution is implemented */ + String *kind = Getattr($6, "kind"); + String *name = Getattr($6, "name"); + $$ = new_node("template"); + Setattr($$,"kind",kind); + Setattr($$,"name",name); + Setattr($$,"sym:weak", "1"); + Setattr($$,"templatetype","classforward"); + Setattr($$,"templateparms", $3); + add_symbols($$); + + if (GetFlag($$, "feature:nestedworkaround")) { + Swig_symbol_remove($$); + $$ = 0; + } else { + SWIG_WARN_NODE_BEGIN($$); + Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested template %s not currently supported (%s ignored).\n", kind, name); + SWIG_WARN_NODE_END($$); + } } Delete($6); - $$ = 0; } else { String *tname = 0; int error = 0; @@ -4394,7 +4412,9 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line Swig_symbol_remove($$); $$ = 0; } else { - Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (%s ignored).\n", $2, $3); + SWIG_WARN_NODE_BEGIN($$); + Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (%s ignored).\n", $2, $3); + SWIG_WARN_NODE_END($$); } } else if ($6.id) { /* Generate some code for a new struct */ @@ -4434,7 +4454,9 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line Swig_symbol_remove($$); $$ = 0; } else { - Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $2, $5.id); + SWIG_WARN_NODE_BEGIN($$); + Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $2, $5.id); + SWIG_WARN_NODE_END($$); } } else { /* Generate some code for a new struct */ @@ -4451,21 +4473,35 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line add_nested(n); } } else { - Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", $2); + Swig_warning(WARN_PARSE_UNNAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", $2); } } } -/* A 'class name : base_list { };' declaration, always ignored */ -/***** - This fixes derived_nested.i, but it adds one shift/reduce. Anyway, - we are waiting for the nested class support. - *****/ +/* class name : base_list { }; declaration */ +/* This adds one shift/reduce. */ + | storage_class cpptype idcolon COLON base_list LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); } SEMI { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { - Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $2, $3); + /* Treat the nested class/struct/union as a forward declaration until a proper nested class solution is implemented */ + $$ = new_node("classforward"); + Setfile($$,cparse_file); + Setline($$,cparse_line); + Setattr($$,"kind",$2); + Setattr($$,"name",$3); + Setattr($$,"sym:weak", "1"); + add_symbols($$); + + if (GetFlag($$, "feature:nestedworkaround")) { + Swig_symbol_remove($$); + $$ = 0; + } else { + SWIG_WARN_NODE_BEGIN($$); + Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (%s ignored).\n", $2, $3); + SWIG_WARN_NODE_END($$); + } } } @@ -4475,7 +4511,7 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line } SEMI { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { - Swig_warning(WARN_PARSE_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $5, $6); + Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $5, $6); } } */ diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 6c54c55bd..b400fbdeb 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -72,7 +72,7 @@ #define WARN_PARSE_PRIVATE_INHERIT 309 #define WARN_PARSE_TEMPLATE_REPEAT 310 #define WARN_PARSE_TEMPLATE_PARTIAL 311 -#define WARN_PARSE_NESTED_CLASS 312 +#define WARN_PARSE_UNNAMED_NESTED_CLASS 312 #define WARN_PARSE_UNDEFINED_EXTERN 313 #define WARN_PARSE_KEYWORD 314 #define WARN_PARSE_USING_UNDEF 315 @@ -85,6 +85,7 @@ #define WARN_PARSE_REDUNDANT 322 #define WARN_PARSE_REC_INHERITANCE 323 #define WARN_PARSE_NESTED_TEMPLATE 324 +#define WARN_PARSE_NAMED_NESTED_CLASS 325 #define WARN_IGNORE_OPERATOR_NEW 350 /* new */ #define WARN_IGNORE_OPERATOR_DELETE 351 /* delete */ From dd5714ea28db35cb31badfc686026aba909c86c3 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 13 Nov 2009 07:15:08 +0000 Subject: [PATCH 230/352] [php] Fix place where class prefix (as specified with -prefix) wasn't being used. Patch from gverbruggen in SF#2892647. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11736 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/php.cxx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 533c64dff..6cfdc012a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2009-11-13: olly + [php] Fix place where class prefix (as specified with -prefix) + wasn't being used. Patch from gverbruggen in SF#2892647. + 2009-11-12: wsfulton Fix usage of nested template classes so that compileable code is generated - the nested template class is now treated like a normal nested classes that is as an opaque type diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index eee4d1fcc..cbad1ee84 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1684,7 +1684,7 @@ public: Printf(output, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix); } Printf(output, "\t\t\tif (!class_exists($c)) {\n"); - Printf(output, "\t\t\t\treturn new %s($r);\n", Getattr(classLookup(d), "sym:name")); + Printf(output, "\t\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name")); Printf(output, "\t\t\t}\n"); Printf(output, "\t\t\treturn new $c($r);\n"); } else { From b502f4fc5aa70e6d16d10787514f0e80d8562a63 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 13 Nov 2009 08:04:01 +0000 Subject: [PATCH 231/352] Fix usage of nested template classes within templated classes so that compileable code is generated. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11737 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 +++++- Examples/test-suite/template_nested.i | 19 +++++++++++++++++++ Source/Swig/stype.c | 8 +++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6cfdc012a..58742c56f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,13 +1,17 @@ Version 1.3.41 (in progress) ============================ +2009-11-13: wsfulton + Fix usage of nested template classes within templated classes so that compileable code + is generated. + 2009-11-13: olly [php] Fix place where class prefix (as specified with -prefix) wasn't being used. Patch from gverbruggen in SF#2892647. 2009-11-12: wsfulton Fix usage of nested template classes so that compileable code is generated - the nested - template class is now treated like a normal nested classes that is as an opaque type + template class is now treated like a normal nested classes, that is, as an opaque type unless the nestedworkaround feature is used. 2009-11-12: wsfulton diff --git a/Examples/test-suite/template_nested.i b/Examples/test-suite/template_nested.i index 86b9230ae..1bb1c686a 100644 --- a/Examples/test-suite/template_nested.i +++ b/Examples/test-suite/template_nested.i @@ -6,8 +6,20 @@ %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterClass::Inner2; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedInnerTemplate1; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedInnerTemplate2; +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedInnerTemplate3; %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) ns::OuterTemplate::NestedStruct; +namespace ns { +template struct ForwardTemplate; +} +%{ +namespace ns { + template struct ForwardTemplate { + void tmethod(T t) {} + }; +} +%} + %inline %{ namespace ns { @@ -80,10 +92,17 @@ namespace ns { void hohum() {} }; UU hohum(UU u) { return u; } + template struct NestedInnerTemplate3 : public NestedInnerTemplate2 { + void hohum() {} + }; struct NestedStruct { NestedStruct() {} void hohum() {} }; + NestedInnerTemplate1 useNestedInnerTemplate1(const NestedInnerTemplate1& inner) { return inner; } + NestedInnerTemplate2 useNestedInnerTemplate2(const NestedInnerTemplate2& inner) { return inner; } + NestedInnerTemplate3 useNestedInnerTemplate3(const NestedInnerTemplate3& inner) { return inner; } + NestedStruct useNestedStruct(const NestedStruct& inner) { return inner; } }; } diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 8a7700bec..aa5d448a3 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -525,7 +525,13 @@ String *SwigType_namestr(const SwigType *t) { Putc(' ', r); Putc('>', r); suffix = SwigType_templatesuffix(t); - Append(r, suffix); + if (Len(suffix) > 0) { + String *suffix_namestr = SwigType_namestr(suffix); + Append(r, suffix_namestr); + Delete(suffix_namestr); + } else { + Append(r, suffix); + } Delete(suffix); Delete(p); return r; From 1b951d68f4194efd46a389ca8bd56a400b224053 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 13 Nov 2009 18:27:41 +0000 Subject: [PATCH 232/352] nested classes code refactor git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11738 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 81 ++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 51 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index f310d489b..886e77fd8 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1428,6 +1428,33 @@ static void default_arguments(Node *n) { } } +/* ----------------------------------------------------------------------------- + * nested_forward_declaration() + * + * Treat the nested class/struct/union as a forward declaration until a proper + * nested class solution is implemented. + * ----------------------------------------------------------------------------- */ + +static Node *nested_forward_declaration(const char *kind, const char *name) { + Node *n = new_node("classforward"); + Setfile(n,cparse_file); + Setline(n,cparse_line); + Setattr(n,"kind", kind); + Setattr(n,"name", name); + Setattr(n,"sym:weak", "1"); + add_symbols(n); + + if (GetFlag(n, "feature:nestedworkaround")) { + Swig_symbol_remove(n); + n = 0; + } else { + SWIG_WARN_NODE_BEGIN(n); + Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", kind, name); + SWIG_WARN_NODE_END(n); + } + return n; +} + /* ----------------------------------------------------------------------------- * tag_nodes() * @@ -4399,23 +4426,7 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { if (cparse_cplusplus) { - /* Treat the nested class/struct/union as a forward declaration until a proper nested class solution is implemented */ - $$ = new_node("classforward"); - Setfile($$,cparse_file); - Setline($$,cparse_line); - Setattr($$,"kind",$2); - Setattr($$,"name",$3); - Setattr($$,"sym:weak", "1"); - add_symbols($$); - - if (GetFlag($$, "feature:nestedworkaround")) { - Swig_symbol_remove($$); - $$ = 0; - } else { - SWIG_WARN_NODE_BEGIN($$); - Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (%s ignored).\n", $2, $3); - SWIG_WARN_NODE_END($$); - } + $$ = nested_forward_declaration($2, $3); } else if ($6.id) { /* Generate some code for a new struct */ Nested *n = (Nested *) malloc(sizeof(Nested)); @@ -4441,23 +4452,7 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line if (cplus_mode == CPLUS_PUBLIC) { if ($5.id) { if (cparse_cplusplus) { - /* Treat the nested class/struct/union as a forward declaration until a proper nested class solution is implemented */ - $$ = new_node("classforward"); - Setfile($$,cparse_file); - Setline($$,cparse_line); - Setattr($$,"kind",$2); - Setattr($$,"name",$5.id); - Setattr($$,"sym:weak", "1"); - add_symbols($$); - - if (GetFlag($$, "feature:nestedworkaround")) { - Swig_symbol_remove($$); - $$ = 0; - } else { - SWIG_WARN_NODE_BEGIN($$); - Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", $2, $5.id); - SWIG_WARN_NODE_END($$); - } + $$ = nested_forward_declaration($2, $5.id); } else { /* Generate some code for a new struct */ Nested *n = (Nested *) malloc(sizeof(Nested)); @@ -4485,23 +4480,7 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line } SEMI { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { - /* Treat the nested class/struct/union as a forward declaration until a proper nested class solution is implemented */ - $$ = new_node("classforward"); - Setfile($$,cparse_file); - Setline($$,cparse_line); - Setattr($$,"kind",$2); - Setattr($$,"name",$3); - Setattr($$,"sym:weak", "1"); - add_symbols($$); - - if (GetFlag($$, "feature:nestedworkaround")) { - Swig_symbol_remove($$); - $$ = 0; - } else { - SWIG_WARN_NODE_BEGIN($$); - Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (%s ignored).\n", $2, $3); - SWIG_WARN_NODE_END($$); - } + $$ = nested_forward_declaration($2, $3); } } From cd53dc68eeb48fab248fdea57293c75ececa4e86 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 13 Nov 2009 18:34:54 +0000 Subject: [PATCH 233/352] remove SWIGMAC and SWIGWIN32/SWIGWIN macros which have no effect git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11739 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Preprocessor.html | 2 -- Source/Modules/main.cxx | 6 ------ 2 files changed, 8 deletions(-) diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 5afa59243..2dd79dac5 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -102,8 +102,6 @@ by SWIG when it is parsing the interface:
       SWIG                            Always defined when SWIG is processing a file
       SWIGIMPORTED                    Defined when SWIG is importing a file with %import
      -SWIGMAC                         Defined when running SWIG on the Macintosh
      -SWIGWIN                         Defined when running SWIG under Windows
       SWIG_VERSION                    Hexadecimal number containing SWIG version,
                                       such as 0x010311 (corresponding to SWIG-1.3.11).
       
      diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
      index 30d12f26b..4903416cd 100644
      --- a/Source/Modules/main.cxx
      +++ b/Source/Modules/main.cxx
      @@ -844,12 +844,6 @@ int SWIG_main(int argc, char *argv[], Language *l) {
       
         Preprocessor_define((DOH *) "SWIG 1", 0);
         Preprocessor_define((DOH *) "__STDC__", 0);
      -#ifdef MACSWIG
      -  Preprocessor_define((DOH *) "SWIGMAC 1", 0);
      -#endif
      -#ifdef SWIGWIN32
      -  Preprocessor_define((DOH *) "SWIGWIN32 1", 0);
      -#endif
       
         // Set the SWIG version value in format 0xAABBCC from package version expected to be in format A.B.C
         String *package_version = NewString(PACKAGE_VERSION); /* Note that the fakeversion has not been set at this point */
      
      From 2bf42357e0e420d024b7a3628d997cd8e93907ae Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Fri, 13 Nov 2009 19:04:28 +0000
      Subject: [PATCH 234/352] fix suggested casts for displaying SWIG types in a
       debugger
      
      git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11740 626c5289-ae23-0410-ae9c-e8d60b6d4f22
      ---
       Doc/Devel/internals.html | 12 ++++++------
       1 file changed, 6 insertions(+), 6 deletions(-)
      
      diff --git a/Doc/Devel/internals.html b/Doc/Devel/internals.html
      index d27ec12fa..63a8626ff 100644
      --- a/Doc/Devel/internals.html
      +++ b/Doc/Devel/internals.html
      @@ -1070,25 +1070,25 @@ With each is the cast that can be used in the debugger to extract the underlying
       

    62. String *s;

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

    64. SwigType *t;

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

      -

    66. String_or_char *sc;
    67. +
    68. const_String_or_char_ptr sc;
    69. Either
      -((String *)((DohBase *)sc)->data)->str +(*(struct String *)(((DohBase *)sc)->data)).str
      or
      (char *)sc
      will work depending on whether the underlying type is really a String * or char *. From 0509dbb95152a25aaa927a96ef70ca0f952b8444 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 13 Nov 2009 19:21:33 +0000 Subject: [PATCH 235/352] some parser code comments added git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11741 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 886e77fd8..81663abf8 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -859,6 +859,12 @@ static String *remove_block(Node *kw, const String *inputcode) { static Node *nscope = 0; static Node *nscope_inner = 0; + +/* Remove the scope prefix from cname and return the base name without the prefix. + * The scopes specified in the prefix are found, or created in the current namespace. + * So ultimately the scope is changed to that required for the base name. + * For example AA::BB::CC as input returns CC and creates the namespace AA then inner + * namespace BB in the current scope. If no scope separator (::) in the input, then nothing happens! */ static String *resolve_node_scope(String *cname) { Symtab *gscope = 0; nscope = 0; @@ -2848,10 +2854,10 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va Swig_symbol_setscope(csyms); } - /* Merge in addmethods for this class */ + /* Merge in %extend methods for this class */ /* !!! This may be broken. We may have to add the - addmethods at the beginning of the class */ + %extend methods at the beginning of the class */ if (extendhash) { String *stmp = 0; From 7ae45bc020e463f6b6ad3062607370b86af8e624 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Nov 2009 15:55:23 +0000 Subject: [PATCH 236/352] Fix #2310483 - function pointer typedef within extern C block. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11742 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Examples/test-suite/common.mk | 1 + Examples/test-suite/extern_c.i | 16 ++++++++++++++++ Examples/test-suite/python/extern_c_runme.py | 4 ++++ Source/CParse/parser.y | 2 +- 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/extern_c.i create mode 100644 Examples/test-suite/python/extern_c_runme.py diff --git a/CHANGES.current b/CHANGES.current index 58742c56f..8469fa815 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.41 (in progress) ============================ +2009-11-14: wsfulton + Fix #2310483 - function pointer typedef within extern "C" block. + 2009-11-13: wsfulton Fix usage of nested template classes within templated classes so that compileable code is generated. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 93c1cc909..d7882a462 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -191,6 +191,7 @@ CPP_TEST_CASES += \ extend_placement \ extend_template \ extend_template_ns \ + extern_c \ extern_namespace \ extern_throws \ features \ diff --git a/Examples/test-suite/extern_c.i b/Examples/test-suite/extern_c.i new file mode 100644 index 000000000..9c17d18fb --- /dev/null +++ b/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/Examples/test-suite/python/extern_c_runme.py b/Examples/test-suite/python/extern_c_runme.py new file mode 100644 index 000000000..1a6d2aa12 --- /dev/null +++ b/Examples/test-suite/python/extern_c_runme.py @@ -0,0 +1,4 @@ +import extern_c + +extern_c.RealFunction(2) + diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 81663abf8..f78d5255b 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -2965,7 +2965,7 @@ c_declaration : c_decl { appendChild($$,n); while (n) { SwigType *decl = Getattr(n,"decl"); - if (SwigType_isfunction(decl)) { + if (SwigType_isfunction(decl) && Strcmp(Getattr(n, "storage"), "typedef") != 0) { Setattr(n,"storage","externc"); } n = nextSibling(n); From e0dd20350f434bce0edc5dfa5c4401c9b77f937c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Nov 2009 21:50:41 +0000 Subject: [PATCH 237/352] Add caveat about using percent in varargs example as per suggestion in bug #2106353 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11743 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/python/class/example.i | 8 +---- Examples/python/class/runme.py | 55 +++++---------------------------- 2 files changed, 8 insertions(+), 55 deletions(-) diff --git a/Examples/python/class/example.i b/Examples/python/class/example.i index 75700b305..aa28dde80 100644 --- a/Examples/python/class/example.i +++ b/Examples/python/class/example.i @@ -1,10 +1,4 @@ /* File : example.i */ %module example -%{ -#include "example.h" -%} - -/* Let's just grab the original header file here */ -%include "example.h" - +int printf(const char *fmt, ...); diff --git a/Examples/python/class/runme.py b/Examples/python/class/runme.py index f1272ae81..54543be67 100644 --- a/Examples/python/class/runme.py +++ b/Examples/python/class/runme.py @@ -1,51 +1,10 @@ -# file: runme.py -# This file illustrates the proxy class C++ interface generated -# by SWIG. +from example import * -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" +printf("hello\n") +name = "%shoot" +num = 22 +printf("Hello %s. Your number is %d\n" % (name, num)) +print("hello there %s." % name); +printf("Your result is 90%.\n") From 22c0c8ea9798ec79dcce647a5eb1c617457f19c7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Nov 2009 21:54:18 +0000 Subject: [PATCH 238/352] Minor change to previous commit about varargs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11744 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Varargs.html | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index f40a1ff1f..fb34a3ad9 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -270,21 +270,37 @@ traceprintf(arg1, NULL);

      Arguably, this approach seems to defeat the whole point of variable length arguments. However, -this actually provides enough support for many simple kinds of varargs functions to still be useful. For -instance, you could make function calls like this (in Python): +this actually provides enough support for many simple kinds of varargs functions to still be useful, however it does come with a caveat. +For instance, you could make function calls like this (in Python):

       >>> traceprintf("Hello World")
       >>> traceprintf("Hello %s. Your number is %d\n" % (name, num))
      +>>> traceprintf("Your result is 90%%.")
       

      Notice how string formatting is being done in Python instead of C. +The caveat is the strings passed must be safe to use in C though. +For example if name was to contain a "%" it should be double escaped in order to avoid unpredictable +behaviour:

      +
      +
      +>>> traceprintf("Your result is 90%.\n")  # unpredictable behaviour
      +>>> traceprintf("Your result is 90%%.\n") # good
      +
      +
      + +

      +Read on for further solutions. +

      + +

      13.4 Argument replacement using %varargs

      From dde16ac54a26f7a844f666396c90f5c72c5df648 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Nov 2009 22:07:51 +0000 Subject: [PATCH 239/352] Removed empty sections git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11745 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Python.html | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index a739543df..fcaebc014 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -3854,15 +3854,6 @@ If you need to return binary data, you might use the also be used to extra binary data from arbitrary pointers.

      -

      31.7.5 Arrays

      - - -

      31.7.6 String arrays

      - - -

      31.7.7 STL wrappers

      - -

      31.8 Typemaps

      From 5ea1852ecb1515ac45fc333bd737ec7931f5c44f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Nov 2009 23:51:12 +0000 Subject: [PATCH 240/352] namespace_union.i now works given recent nested class improvements. Closes bug #811906 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11746 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 2 +- Examples/test-suite/namespace_union.i | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index d7882a462..c8ca09013 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -80,7 +80,6 @@ CPP_TEST_BROKEN += \ exception_partial_info \ extend_variable \ li_std_vector_ptr \ - namespace_union \ nested_structs \ overload_complicated \ template_default_pointer \ @@ -241,6 +240,7 @@ CPP_TEST_CASES += \ namespace_template \ namespace_typedef_class \ namespace_typemap \ + namespace_union \ namespace_virtual_method \ naturalvar \ nested_class \ diff --git a/Examples/test-suite/namespace_union.i b/Examples/test-suite/namespace_union.i index edade9640..70698682e 100644 --- a/Examples/test-suite/namespace_union.i +++ b/Examples/test-suite/namespace_union.i @@ -1,4 +1,7 @@ %module namespace_union + +%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) SpatialIndex::Variant::val; + %inline %{ namespace SpatialIndex { From 107c61d979480a4777e836f019dc1ea2530e6c56 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 15 Nov 2009 00:05:25 +0000 Subject: [PATCH 241/352] Remove bugs which have been fixed over time from cpp_broken.i git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11747 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/cpp_broken.i | 63 -------------------------------- 1 file changed, 63 deletions(-) diff --git a/Examples/test-suite/cpp_broken.i b/Examples/test-suite/cpp_broken.i index fe109ea43..84d6122e5 100644 --- a/Examples/test-suite/cpp_broken.i +++ b/Examples/test-suite/cpp_broken.i @@ -1,36 +1,6 @@ %module cpp_broken -// bug #1060789 -%inline %{ -#define MASK(shift, size) (((1 << (size)) - 1) << (shift)) -#define SOME_MASK_DEF (80*MASK(8, 10)) -%} - -// bug #1060079 -%inline %{ -#define FIELD(name, width) unsigned int name:width -#define SOME_CONST 2 -#define NEXT_CONST (2 * SOME_CONST) - -typedef struct { -FIELD(a, SOME_CONST); -FIELD(b, NEXT_CONST); -} MyStruct_t; -%} - -%{ -#ifdef max -#undef max -#endif -%} - -// bug #994301 -%inline %{ -#define max(a,b) ((a) > (b) ? (a) : (b)) -%} - - // bug #940318 %inline %{ typedef enum { @@ -40,36 +10,3 @@ eZero = 0 %} -// bug #754443 - -%inline %{ -#define MAG_STYLE_BORDER_OFFS 0 -#define MAG_STYLE_BORDER_BITS 3 -#define MAG_STYLE_BORDER_MASK (((1UL< Date: Sun, 15 Nov 2009 00:36:22 +0000 Subject: [PATCH 242/352] Fix #1960977 - Syntax error parsing derived nested class declaration and member variable instance git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11748 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/derived_nested.i | 2 ++ Source/CParse/parser.y | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 8469fa815..3d5c27950 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2009-11-15: wsfulton + Fix #1960977 - Syntax error parsing derived nested class declaration and member + variable instance. + 2009-11-14: wsfulton Fix #2310483 - function pointer typedef within extern "C" block. diff --git a/Examples/test-suite/derived_nested.i b/Examples/test-suite/derived_nested.i index 9a7cfce07..29114d5a0 100644 --- a/Examples/test-suite/derived_nested.i +++ b/Examples/test-suite/derived_nested.i @@ -6,6 +6,7 @@ This was reported in bug #909389 */ %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 %{ @@ -19,6 +20,7 @@ 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/Source/CParse/parser.y b/Source/CParse/parser.y index f78d5255b..b87ba9368 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -4483,7 +4483,7 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line /* This adds one shift/reduce. */ | storage_class cpptype idcolon COLON base_list LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); - } SEMI { + } cpp_opt_declarators { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { $$ = nested_forward_declaration($2, $3); From 7fd36f5bd6c28331cf9375dc9d35fb5c58aecce3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Nov 2009 18:45:53 +0000 Subject: [PATCH 243/352] Fix parsing of struct declaration and initialization git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11750 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 7 +++++ Examples/test-suite/common.mk | 2 ++ .../python/struct_initialization_runme.py | 20 ++++++++++++ Examples/test-suite/struct_initialization.i | 31 +++++++++++++++++++ .../test-suite/struct_initialization_cpp.i | 5 +++ Source/CParse/parser.y | 10 +++--- 6 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 Examples/test-suite/python/struct_initialization_runme.py create mode 100644 Examples/test-suite/struct_initialization.i create mode 100644 Examples/test-suite/struct_initialization_cpp.i diff --git a/CHANGES.current b/CHANGES.current index 3d5c27950..e97bbc58a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,13 @@ Version 1.3.41 (in progress) ============================ +2009-11-17: wsfulton + Fix parsing of struct declaration and initialization, for example: + + struct S { + int x; + } instance = { 10 }; + 2009-11-15: wsfulton Fix #1960977 - Syntax error parsing derived nested class declaration and member variable instance. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index c8ca09013..db28917ef 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -303,6 +303,7 @@ CPP_TEST_CASES += \ static_array_member \ static_const_member \ static_const_member_2 \ + struct_initialization_cpp \ struct_value \ template \ template_arg_replace \ @@ -470,6 +471,7 @@ C_TEST_CASES += \ sizeof_pointer \ sneaky1 \ struct_rename \ + struct_initialization \ typedef_struct \ typemap_subst \ union_parameter \ diff --git a/Examples/test-suite/python/struct_initialization_runme.py b/Examples/test-suite/python/struct_initialization_runme.py new file mode 100644 index 000000000..fbed6a5e9 --- /dev/null +++ b/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/Examples/test-suite/struct_initialization.i b/Examples/test-suite/struct_initialization.i new file mode 100644 index 000000000..c378ba31d --- /dev/null +++ b/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/Examples/test-suite/struct_initialization_cpp.i b/Examples/test-suite/struct_initialization_cpp.i new file mode 100644 index 000000000..dc47077b5 --- /dev/null +++ b/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/Source/CParse/parser.y b/Source/CParse/parser.y index b87ba9368..0da3666f8 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3546,7 +3546,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { Classprefix = NewStringEmpty(); Delete(Namespaceprefix); Namespaceprefix = Swig_symbol_qualifiedscopename(0); - } cpp_members RBRACE declarator c_decl_tail { + } cpp_members RBRACE declarator initializer c_decl_tail { String *unnamed; Node *n; Classprefix = 0; @@ -3564,8 +3564,8 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { Setattr(n,"decl",$7.type); Setattr(n,"parms",$7.parms); Setattr(n,"storage",$1); - if ($8) { - Node *p = $8; + if ($9) { + Node *p = $9; set_nextSibling(n,p); while (p) { String *type = Copy(unnamed); @@ -3635,12 +3635,12 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { ; cpp_opt_declarators : SEMI { $$ = 0; } - | declarator c_decl_tail { + | declarator initializer c_decl_tail { $$ = new_node("cdecl"); Setattr($$,"name",$1.id); Setattr($$,"decl",$1.type); Setattr($$,"parms",$1.parms); - set_nextSibling($$,$2); + set_nextSibling($$,$3); } ; /* ------------------------------------------------------------ From f62c54c0f6d8a177580c9a715321f54cddae0e2c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Nov 2009 19:28:29 +0000 Subject: [PATCH 244/352] add missing nested_workaround runtime test git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11751 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../java/nested_workaround_runme.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Examples/test-suite/java/nested_workaround_runme.java diff --git a/Examples/test-suite/java/nested_workaround_runme.java b/Examples/test-suite/java/nested_workaround_runme.java new file mode 100644 index 000000000..761a2da8e --- /dev/null +++ b/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"); + } + } +} From 7cb4e902d59aa73009cd4f928d5470fa68803f36 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Nov 2009 19:31:13 +0000 Subject: [PATCH 245/352] Fix parsing of enum declaration and initialization git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11752 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 9 +++++++++ Examples/test-suite/enums.i | 20 ++++++++++++++++++-- Examples/test-suite/octave/enums_runme.m | 16 ++++++++++++++++ Examples/test-suite/python/enums_runme.py | 12 ++++++++++++ Source/CParse/parser.y | 6 +++--- 5 files changed, 58 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index e97bbc58a..bc28d8fc1 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,15 @@ Version 1.3.41 (in progress) ============================ +2009-11-17: wsfulton + Fix parsing of enum declaration and initialization, for example: + + enum ABC { + a, + b, + c + } A = a, *pC = &C, array[3] = {a, b, c}; + 2009-11-17: wsfulton Fix parsing of struct declaration and initialization, for example: diff --git a/Examples/test-suite/enums.i b/Examples/test-suite/enums.i index 00499f800..40be28e94 100644 --- a/Examples/test-suite/enums.i +++ b/Examples/test-suite/enums.i @@ -8,6 +8,7 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance1; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance2; %warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance3; +%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); %inline %{ @@ -64,7 +65,7 @@ typedef struct _iFoo enum { Phoo = +50, Char = 'a' - } e; + } e; } iFoo; %} #else @@ -77,5 +78,20 @@ struct iFoo }; }; %} - #endif + +// enum declaration and initialization +%inline %{ +enum Exclamation { + goodness, + gracious, + me +} enumInstance = me; + +enum ContainYourself { + slap = 10, + my, + thigh +} Slap = slap, My = my, Thigh = thigh, *pThigh = &Thigh, arrayContainYourself[3] = {slap, my, thigh}; +%} + diff --git a/Examples/test-suite/octave/enums_runme.m b/Examples/test-suite/octave/enums_runme.m index 91f2ce2bf..789f7c9e4 100644 --- a/Examples/test-suite/octave/enums_runme.m +++ b/Examples/test-suite/octave/enums_runme.m @@ -5,3 +5,19 @@ 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.My != 11) + error +endif + +if (enums.cvar.Thigh != 12) + error +endif + diff --git a/Examples/test-suite/python/enums_runme.py b/Examples/test-suite/python/enums_runme.py index 59a982974..e8dbe6942 100644 --- a/Examples/test-suite/python/enums_runme.py +++ b/Examples/test-suite/python/enums_runme.py @@ -5,3 +5,15 @@ _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.My != 11: + raise RuntimeError + +if _enums.cvar.Thigh != 12: + raise RuntimeError + diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 0da3666f8..8b4521ef1 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3132,7 +3132,7 @@ c_enum_decl : storage_class ENUM ename LBRACE enumlist RBRACE SEMI { add_symbols($$); /* Add to tag space */ add_symbols($5); /* Add enum values to id space */ } - | storage_class ENUM ename LBRACE enumlist RBRACE declarator c_decl_tail { + | storage_class ENUM ename LBRACE enumlist RBRACE declarator initializer c_decl_tail { Node *n; SwigType *ty = 0; String *unnamed = 0; @@ -3174,8 +3174,8 @@ c_enum_decl : storage_class ENUM ename LBRACE enumlist RBRACE SEMI { SetFlag(n,"unnamedinstance"); Delete(cty); } - if ($8) { - Node *p = $8; + if ($9) { + Node *p = $9; set_nextSibling(n,p); while (p) { SwigType *cty = Copy(ty); From a9ccc5a8662ea11776ab5c1b0aad66fade8086bf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 18 Nov 2009 20:24:06 +0000 Subject: [PATCH 246/352] Fix multiple declarations of nested structs (C code) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11753 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 8 + Examples/test-suite/common.mk | 2 +- .../test-suite/java/nested_structs_runme.java | 37 ++++ Examples/test-suite/nested_class.i | 5 + Examples/test-suite/nested_structs.i | 25 ++- Source/CParse/parser.y | 179 ++++++++++-------- 6 files changed, 176 insertions(+), 80 deletions(-) create mode 100644 Examples/test-suite/java/nested_structs_runme.java diff --git a/CHANGES.current b/CHANGES.current index bc28d8fc1..e00984fe0 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,14 @@ Version 1.3.41 (in progress) ============================ +2009-11-18: wsfulton + Fix #491476 - multiple declarations of nested structs, for example: + struct Outer { + struct { + int val; + } inner1, inner2, *inner3, inner4[1]; + } outer; + 2009-11-17: wsfulton Fix parsing of enum declaration and initialization, for example: diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index db28917ef..f9e06c0c4 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -80,7 +80,6 @@ CPP_TEST_BROKEN += \ exception_partial_info \ extend_variable \ li_std_vector_ptr \ - nested_structs \ overload_complicated \ template_default_pointer \ template_expr @@ -461,6 +460,7 @@ C_TEST_CASES += \ long_long \ name \ nested \ + nested_structs \ newobject2 \ overload_extend \ overload_extendc \ diff --git a/Examples/test-suite/java/nested_structs_runme.java b/Examples/test-suite/java/nested_structs_runme.java new file mode 100644 index 000000000..6e103cd12 --- /dev/null +++ b/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/Examples/test-suite/nested_class.i b/Examples/test-suite/nested_class.i index cccebb136..89c9a8058 100644 --- a/Examples/test-suite/nested_class.i +++ b/Examples/test-suite/nested_class.i @@ -104,6 +104,11 @@ struct Outer { InnerStruct4* getInnerStruct4() { return 0; } InnerClass4* getInnerClass4() { return 0; } InnerUnion4* getInnerUnion4() { return 0; } + + /////////////////////////////////////////// + struct InnerMultiple { + Integer x; + } MultipleInstance1, MultipleInstance2; }; %} diff --git a/Examples/test-suite/nested_structs.i b/Examples/test-suite/nested_structs.i index 41cdd63fb..60e34a638 100644 --- a/Examples/test-suite/nested_structs.i +++ b/Examples/test-suite/nested_structs.i @@ -2,11 +2,26 @@ // bug #491476 %inline %{ -struct { -struct { -int a; -} a, b; -} a; +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/Source/CParse/parser.y b/Source/CParse/parser.y index 8b4521ef1..c7ca713f0 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -985,18 +985,16 @@ static String *resolve_node_scope(String *cname) { - - /* Structures for handling code fragments built for nested classes */ typedef struct Nested { String *code; /* Associated code fragment */ int line; /* line number where it starts */ - char *name; /* Name associated with this nested class */ - char *kind; /* Kind of class */ + const char *name; /* Name associated with this nested class */ + const char *kind; /* Kind of class */ int unnamed; /* unnamed class */ SwigType *type; /* Datatype associated with the name */ - struct Nested *next; /* Next code fragment in list */ + struct Nested *next; /* Next code fragment in list */ } Nested; /* Some internal variables for saving nested class information */ @@ -1006,15 +1004,96 @@ static Nested *nested_list = 0; /* Add a function to the nested list */ static void add_nested(Nested *n) { - Nested *n1; - if (!nested_list) nested_list = n; - else { - n1 = nested_list; - while (n1->next) n1 = n1->next; + if (!nested_list) { + nested_list = n; + } else { + Nested *n1 = nested_list; + while (n1->next) + n1 = n1->next; n1->next = n; } } +/* ----------------------------------------------------------------------------- + * nested_new_struct() + * + * Nested struct handling creates a global struct from the nested struct. + * ----------------------------------------------------------------------------- */ + +static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, String *struct_code) { + String *name; + String *decl; + + /* Create a new global struct declaration which is just a copy of the nested struct */ + Nested *nested = (Nested *) malloc(sizeof(Nested)); + Nested *n = nested; + + name = Getattr(cpp_opt_declarators, "name"); + decl = Getattr(cpp_opt_declarators, "decl"); + n->code = NewStringEmpty(); + Printv(n->code, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); + n->name = Swig_copy_string(Char(name)); + n->line = cparse_start_line; + n->type = NewStringEmpty(); + n->kind = kind; + n->unnamed = 0; + SwigType_push(n->type, decl); + n->next = 0; + + /* Repeat for any multiple instances of the nested struct */ + { + Node *p = cpp_opt_declarators; + p = nextSibling(p); + while (p) { + Nested *nn = (Nested *) malloc(sizeof(Nested)); + + name = Getattr(p, "name"); + decl = Getattr(p, "decl"); + nn->code = NewStringEmpty(); + Printv(nn->code, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); + nn->name = Swig_copy_string(Char(name)); + nn->line = cparse_start_line; + nn->type = NewStringEmpty(); + nn->kind = kind; + nn->unnamed = 0; + SwigType_push(nn->type, decl); + nn->next = 0; + n->next = nn; + n = nn; + p = nextSibling(p); + } + } + + add_nested(nested); +} + +/* ----------------------------------------------------------------------------- + * nested_forward_declaration() + * + * Treat the nested class/struct/union as a forward declaration until a proper + * nested class solution is implemented. + * ----------------------------------------------------------------------------- */ + +static Node *nested_forward_declaration(const char *kind, const char *name) { + Node *n = new_node("classforward"); + Setfile(n,cparse_file); + Setline(n,cparse_line); + Setattr(n,"kind", kind); + Setattr(n,"name", name); + Setattr(n,"sym:weak", "1"); + add_symbols(n); + + if (GetFlag(n, "feature:nestedworkaround")) { + Swig_symbol_remove(n); + n = 0; + } else { + SWIG_WARN_NODE_BEGIN(n); + Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", kind, name); + SWIG_WARN_NODE_END(n); + } + return n; +} + /* Strips C-style and C++-style comments from string in-place. */ static void strip_comments(char *string) { int state = 0; /* @@ -1434,33 +1513,6 @@ static void default_arguments(Node *n) { } } -/* ----------------------------------------------------------------------------- - * nested_forward_declaration() - * - * Treat the nested class/struct/union as a forward declaration until a proper - * nested class solution is implemented. - * ----------------------------------------------------------------------------- */ - -static Node *nested_forward_declaration(const char *kind, const char *name) { - Node *n = new_node("classforward"); - Setfile(n,cparse_file); - Setline(n,cparse_line); - Setattr(n,"kind", kind); - Setattr(n,"name", name); - Setattr(n,"sym:weak", "1"); - add_symbols(n); - - if (GetFlag(n, "feature:nestedworkaround")) { - Swig_symbol_remove(n); - n = 0; - } else { - SWIG_WARN_NODE_BEGIN(n); - Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", kind, name); - SWIG_WARN_NODE_END(n); - } - return n; -} - /* ----------------------------------------------------------------------------- * tag_nodes() * @@ -1609,7 +1661,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %type pragma_arg; %type includetype; %type pointer primitive_type; -%type declarator direct_declarator notso_direct_declarator parameter_declarator typemap_parameter_declarator nested_decl; +%type declarator direct_declarator notso_direct_declarator parameter_declarator typemap_parameter_declarator; %type abstract_declarator direct_abstract_declarator ctor_end; %type typemap_type; %type idcolon idcolontail idcolonnt idcolontailnt idtemplate stringbrace stringbracesemi; @@ -4427,56 +4479,40 @@ cpp_protection_decl : PUBLIC COLON { /* struct sname { } id; or struct sname { }; declaration */ -cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); - } nested_decl SEMI { +cpp_nested : storage_class cpptype ID LBRACE { + cparse_start_line = cparse_line; skip_balanced('{','}'); + $$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */ + } cpp_opt_declarators { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { if (cparse_cplusplus) { $$ = nested_forward_declaration($2, $3); - } else if ($6.id) { - /* Generate some code for a new struct */ - Nested *n = (Nested *) malloc(sizeof(Nested)); - n->code = NewStringEmpty(); - Printv(n->code, "typedef ", $2, " ", Char(scanner_ccode), " $classname_", $6.id, ";\n", NIL); - n->name = Swig_copy_string($6.id); - n->line = cparse_start_line; - n->type = NewStringEmpty(); - n->kind = $2; - n->unnamed = 0; - SwigType_push(n->type, $6.type); - n->next = 0; - add_nested(n); + } else if ($6) { + nested_new_struct($6, $2, $5); } } + Delete($5); } /* struct { } id; or struct { }; declaration */ - | storage_class cpptype LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); - } nested_decl SEMI { + | storage_class cpptype LBRACE { + cparse_start_line = cparse_line; skip_balanced('{','}'); + $$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */ + } cpp_opt_declarators { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { - if ($5.id) { + if ($5) { if (cparse_cplusplus) { - $$ = nested_forward_declaration($2, $5.id); + $$ = nested_forward_declaration($2, Getattr($5, "name")); } else { - /* Generate some code for a new struct */ - Nested *n = (Nested *) malloc(sizeof(Nested)); - n->code = NewStringEmpty(); - Printv(n->code, "typedef ", $2, " " , Char(scanner_ccode), " $classname_", $5.id, ";\n",NIL); - n->name = Swig_copy_string($5.id); - n->line = cparse_start_line; - n->type = NewStringEmpty(); - n->kind = $2; - n->unnamed = 1; - SwigType_push(n->type,$5.type); - n->next = 0; - add_nested(n); + nested_new_struct($5, $2, $4); } } else { Swig_warning(WARN_PARSE_UNNAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", $2); } } + Delete($4); } /* class name : base_list { }; declaration */ @@ -4502,11 +4538,6 @@ cpp_nested : storage_class cpptype ID LBRACE { cparse_start_line = cparse_line */ ; -nested_decl : declarator { $$ = $1;} - | empty { $$.id = 0; } - ; - - /* These directives can be included inside a class definition */ cpp_swig_directive: pragma_directive { $$ = $1; } From aa6712e3f2d39bb38e42f897508f323aad0023ee Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 18 Nov 2009 20:37:23 +0000 Subject: [PATCH 247/352] pretty print the nested structs generated as global structs git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11754 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index c7ca713f0..bf437cd66 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1021,6 +1021,7 @@ static void add_nested(Nested *n) { * ----------------------------------------------------------------------------- */ static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, String *struct_code) { + String *new_struct_decl; String *name; String *decl; @@ -1030,8 +1031,13 @@ static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, Strin name = Getattr(cpp_opt_declarators, "name"); decl = Getattr(cpp_opt_declarators, "decl"); + n->code = NewStringEmpty(); - Printv(n->code, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); + new_struct_decl = NewStringEmpty(); + Printv(new_struct_decl, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); + Wrapper_pretty_print(new_struct_decl, n->code); + Delete(new_struct_decl); + n->name = Swig_copy_string(Char(name)); n->line = cparse_start_line; n->type = NewStringEmpty(); @@ -1049,8 +1055,13 @@ static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, Strin name = Getattr(p, "name"); decl = Getattr(p, "decl"); + + new_struct_decl = NewStringEmpty(); nn->code = NewStringEmpty(); - Printv(nn->code, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); + Printv(new_struct_decl, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); + Wrapper_pretty_print(new_struct_decl, n->code); + Delete(new_struct_decl); + nn->name = Swig_copy_string(Char(name)); nn->line = cparse_start_line; nn->type = NewStringEmpty(); From 43b6292681c8fd9629b1b4ebf39a87afd42a6952 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 18 Nov 2009 23:59:10 +0000 Subject: [PATCH 248/352] Nested struct pretty print rewrite and fix. The wrappers for C nested structs are now generated in the same order as declared in the parsed code. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11755 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/CParse/parser.y | 47 ++++++++++++++---------------------------- 2 files changed, 20 insertions(+), 31 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index e00984fe0..10056a24b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2009-11-18: wsfulton + The wrappers for C nested structs are now generated in the same order as declared + in the parsed code. + 2009-11-18: wsfulton Fix #491476 - multiple declarations of nested structs, for example: struct Outer { diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index bf437cd66..431190790 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1021,7 +1021,6 @@ static void add_nested(Nested *n) { * ----------------------------------------------------------------------------- */ static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, String *struct_code) { - String *new_struct_decl; String *name; String *decl; @@ -1033,11 +1032,7 @@ static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, Strin decl = Getattr(cpp_opt_declarators, "decl"); n->code = NewStringEmpty(); - new_struct_decl = NewStringEmpty(); - Printv(new_struct_decl, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); - Wrapper_pretty_print(new_struct_decl, n->code); - Delete(new_struct_decl); - + Printv(n->code, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); n->name = Swig_copy_string(Char(name)); n->line = cparse_start_line; n->type = NewStringEmpty(); @@ -1056,12 +1051,8 @@ static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, Strin name = Getattr(p, "name"); decl = Getattr(p, "decl"); - new_struct_decl = NewStringEmpty(); nn->code = NewStringEmpty(); - Printv(new_struct_decl, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); - Wrapper_pretty_print(new_struct_decl, n->code); - Delete(new_struct_decl); - + Printv(nn->code, "typedef ", kind, " ", struct_code, " $classname_", name, ";\n", NIL); nn->name = Swig_copy_string(Char(name)); nn->line = cparse_start_line; nn->type = NewStringEmpty(); @@ -1176,6 +1167,7 @@ static void strip_comments(char *string) { static Node *dump_nested(const char *parent) { Nested *n,*n1; Node *ret = 0; + Node *last = 0; n = nested_list; if (!parent) { nested_list = 0; @@ -1205,20 +1197,12 @@ static Node *dump_nested(const char *parent) { add_symbols(retx); if (ret) { - set_nextSibling(retx,ret); - Delete(ret); + set_nextSibling(last, retx); + Delete(retx); + } else { + ret = retx; } - ret = retx; - - /* Insert a forward class declaration */ - /* Disabled: [ 597599 ] union in class: incorrect scope - retx = new_node("classforward"); - Setattr(retx,"kind",n->kind); - Setattr(retx,"name",Copy(n->type)); - Setattr(retx,"sym:name", make_name(n->type,0)); - set_nextSibling(retx,ret); - ret = retx; - */ + last = retx; /* Strip comments - further code may break in presence of comments. */ strip_comments(Char(n->code)); @@ -1267,17 +1251,18 @@ static Node *dump_nested(const char *parent) { } } { - Node *head = new_node("insert"); - String *code = NewStringf("\n%s\n",n->code); - Setattr(head,"code", code); + Node *newnode = new_node("insert"); + String *code = NewStringEmpty(); + Wrapper_pretty_print(n->code, code); + Setattr(newnode,"code", code); Delete(code); - set_nextSibling(head,ret); - Delete(ret); - ret = head; + set_nextSibling(last, newnode); + Delete(newnode); + last = newnode; } /* Dump the code to the scanner */ - start_inline(Char(n->code),n->line); + start_inline(Char(Getattr(last, "code")),n->line); n1 = n->next; Delete(n->code); From 2a59a2e6a9c411be9da20de1c42869eaf4d91a1b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 23 Nov 2009 23:02:01 +0000 Subject: [PATCH 249/352] Improved C++ nested class support - nested typedef'd classes now parsed and treated as forward class declaration git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11756 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 + .../test-suite/java/nested_class_runme.java | 72 ++++++++ Examples/test-suite/namespace_union.i | 2 +- Examples/test-suite/nested_class.i | 144 ++++++++++++--- Examples/test-suite/nested_comment.i | 31 ++-- Source/CParse/parser.y | 168 ++++++++++++------ 6 files changed, 324 insertions(+), 99 deletions(-) create mode 100644 Examples/test-suite/java/nested_class_runme.java diff --git a/CHANGES.current b/CHANGES.current index 10056a24b..bed2fea3f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.41 (in progress) ============================ +2009-11-23: wsfulton + C++ nested typedef classes can now be handled too, for example: + struct Outer { + typedef Foo { } FooTypedef1, FooTypedef2; + }; + 2009-11-18: wsfulton The wrappers for C nested structs are now generated in the same order as declared in the parsed code. diff --git a/Examples/test-suite/java/nested_class_runme.java b/Examples/test-suite/java/nested_class_runme.java new file mode 100644 index 000000000..f1c67a0af --- /dev/null +++ b/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/Examples/test-suite/namespace_union.i b/Examples/test-suite/namespace_union.i index 70698682e..85885f399 100644 --- a/Examples/test-suite/namespace_union.i +++ b/Examples/test-suite/namespace_union.i @@ -1,6 +1,6 @@ %module namespace_union -%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) SpatialIndex::Variant::val; +#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS %inline %{ namespace SpatialIndex diff --git a/Examples/test-suite/nested_class.i b/Examples/test-suite/nested_class.i index 89c9a8058..71d91f022 100644 --- a/Examples/test-suite/nested_class.i +++ b/Examples/test-suite/nested_class.i @@ -7,12 +7,18 @@ %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::InnerClass3Name; -%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct3Name; -%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion3Name; -%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass4; -%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct4; -%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion4; +%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 { @@ -51,64 +57,150 @@ struct Outer { class InnerClass2 { public: Integer x; - } InnerClass2Name; + } InnerClass2Instance; struct InnerStruct2 { Integer x; - } InnerStruct2Name; + } InnerStruct2Instance; union InnerUnion2 { Integer x; double y; - } InnerUnion2Name; + } InnerUnion2Instance; /////////////////////////////////////////// class { public: Integer x; - } InnerClass3Name; + } InnerClass3Instance; struct { Integer x; - } InnerStruct3Name; + } InnerStruct3Instance; union { Integer x; double y; - } InnerUnion3Name; + } InnerUnion3Instance; /////////////////////////////////////////// typedef class { public: Integer x; - } InnerClass4; + } InnerClass4Typedef; typedef struct { Integer x; - } InnerStruct4; + } InnerStruct4Typedef; typedef union { Integer x; double y; - } InnerUnion4; + } 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* getInnerStruct1() { return 0; } - InnerClass1* getInnerClass1() { return 0; } - InnerUnion1* getInnerUnion1() { return 0; } + InnerStruct1* makeInnerStruct1() { return 0; } + InnerClass1* makeInnerClass1() { return 0; } + InnerUnion1* makeInnerUnion1() { return 0; } - InnerStruct2* getInnerStruct2() { return 0; } - InnerClass2* getInnerClass2() { return 0; } - InnerUnion2* getInnerUnion2() { return 0; } + InnerStruct2* makeInnerStruct2() { return 0; } + InnerClass2* makeInnerClass2() { return 0; } + InnerUnion2* makeInnerUnion2() { return 0; } - InnerStruct4* getInnerStruct4() { return 0; } - InnerClass4* getInnerClass4() { return 0; } - InnerUnion4* getInnerUnion4() { 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; + } 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/Examples/test-suite/nested_comment.i b/Examples/test-suite/nested_comment.i index c246b8dab..99d0ffb43 100644 --- a/Examples/test-suite/nested_comment.i +++ b/Examples/test-suite/nested_comment.i @@ -1,26 +1,25 @@ %module nested_comment -%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) s1::n; -%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) a::d; +#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; + 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 diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 431190790..46485593f 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1017,10 +1017,21 @@ static void add_nested(Nested *n) { /* ----------------------------------------------------------------------------- * nested_new_struct() * - * Nested struct handling creates a global struct from the nested struct. + * Nested struct handling for C code only creates a global struct from the nested struct. + * + * Nested structure. This is a sick "hack". If we encounter + * a nested structure, we're going to grab the text of its definition and + * feed it back into the scanner. In the meantime, we need to grab + * variable declaration information and generate the associated wrapper + * code later. Yikes! + * + * This really only works in a limited sense. Since we use the + * code attached to the nested class to generate both C code + * it can't have any SWIG directives in it. It also needs to be parsable + * by SWIG or this whole thing is going to puke. * ----------------------------------------------------------------------------- */ -static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, String *struct_code) { +static void nested_new_struct(const char *kind, String *struct_code, Node *cpp_opt_declarators) { String *name; String *decl; @@ -1072,28 +1083,76 @@ static void nested_new_struct(Node *cpp_opt_declarators, const char *kind, Strin /* ----------------------------------------------------------------------------- * nested_forward_declaration() * + * Nested struct handling for C++ code only. + * * Treat the nested class/struct/union as a forward declaration until a proper * nested class solution is implemented. * ----------------------------------------------------------------------------- */ -static Node *nested_forward_declaration(const char *kind, const char *name) { - Node *n = new_node("classforward"); - Setfile(n,cparse_file); - Setline(n,cparse_line); - Setattr(n,"kind", kind); - Setattr(n,"name", name); - Setattr(n,"sym:weak", "1"); - add_symbols(n); +static Node *nested_forward_declaration(const char *storage, const char *kind, String *sname, const char *name, Node *cpp_opt_declarators) { + Node *nn = 0; + int warned = 0; - if (GetFlag(n, "feature:nestedworkaround")) { - Swig_symbol_remove(n); - n = 0; - } else { - SWIG_WARN_NODE_BEGIN(n); - Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", kind, name); - SWIG_WARN_NODE_END(n); + if (sname) { + /* Add forward declaration of the nested type */ + Node *n = new_node("classforward"); + Setfile(n, cparse_file); + Setline(n, cparse_line); + Setattr(n, "kind", kind); + Setattr(n, "name", sname); + Setattr(n, "storage", storage); + Setattr(n, "sym:weak", "1"); + add_symbols(n); + nn = n; } - return n; + + /* Add any variable instances. Also add in any further typedefs of the nested type. + Note that anonymous typedefs (eg typedef struct {...} a, b;) are treated as class forward declarations */ + if (cpp_opt_declarators) { + int storage_typedef = (storage && (strcmp(storage, "typedef") == 0)); + int variable_of_anonymous_type = !sname && !storage_typedef; + if (!variable_of_anonymous_type) { + int anonymous_typedef = !sname && (storage && (strcmp(storage, "typedef") == 0)); + Node *n = cpp_opt_declarators; + SwigType *type = NewString(name); + while (n) { + Setattr(n, "type", type); + Setattr(n, "storage", storage); + if (anonymous_typedef) { + Setattr(n, "nodeType", "classforward"); + Setattr(n, "sym:weak", "1"); + } + n = nextSibling(n); + } + Delete(type); + add_symbols(cpp_opt_declarators); + + if (nn) { + set_nextSibling(nn, cpp_opt_declarators); + } else { + nn = cpp_opt_declarators; + } + } + } + + if (nn && Equal(nodeType(nn), "classforward")) { + Node *n = nn; + if (GetFlag(n, "feature:nestedworkaround")) { + Swig_symbol_remove(n); + nn = 0; + warned = 1; + } else { + SWIG_WARN_NODE_BEGIN(n); + Swig_warning(WARN_PARSE_NAMED_NESTED_CLASS, cparse_file, cparse_line,"Nested %s not currently supported (%s ignored)\n", kind, sname ? sname : name); + SWIG_WARN_NODE_END(n); + warned = 1; + } + } + + if (!warned) + Swig_warning(WARN_PARSE_UNNAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", kind); + + return nn; } /* Strips C-style and C++-style comments from string in-place. */ @@ -4460,67 +4519,64 @@ cpp_protection_decl : PUBLIC COLON { ; -/* ---------------------------------------------------------------------- - Nested structure. This is a sick "hack". If we encounter - a nested structure, we're going to grab the text of its definition and - feed it back into the scanner. In the meantime, we need to grab - variable declaration information and generate the associated wrapper - code later. Yikes! +/* ------------------------------------------------------------ + Named nested structs: + struct sname { }; + struct sname { } id; + struct sname : bases { }; + struct sname : bases { } id; + typedef sname struct { } td; + typedef sname struct : bases { } td; - This really only works in a limited sense. Since we use the - code attached to the nested class to generate both C/C++ code, - it can't have any SWIG directives in it. It also needs to be parsable - by SWIG or this whole thing is going to puke. - ---------------------------------------------------------------------- */ + Adding inheritance, ie replacing 'ID' with 'idcolon inherit' + added one shift/reduce + ------------------------------------------------------------ */ -/* struct sname { } id; or struct sname { }; declaration */ - -cpp_nested : storage_class cpptype ID LBRACE { +cpp_nested : storage_class cpptype idcolon inherit LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); $$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */ } cpp_opt_declarators { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { if (cparse_cplusplus) { - $$ = nested_forward_declaration($2, $3); - } else if ($6) { - nested_new_struct($6, $2, $5); + $$ = nested_forward_declaration($1, $2, $3, $3, $7); + } else if ($7) { + nested_new_struct($2, $6, $7); } } - Delete($5); + Delete($6); } -/* struct { } id; or struct { }; declaration */ +/* ------------------------------------------------------------ + Unnamed/anonymous nested structs: + struct { }; + struct { } id; + struct : bases { }; + struct : bases { } id; + typedef struct { } td; + typedef struct : bases { } td; + ------------------------------------------------------------ */ - | storage_class cpptype LBRACE { + | storage_class cpptype inherit LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); $$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */ } cpp_opt_declarators { $$ = 0; if (cplus_mode == CPLUS_PUBLIC) { - if ($5) { - if (cparse_cplusplus) { - $$ = nested_forward_declaration($2, Getattr($5, "name")); - } else { - nested_new_struct($5, $2, $4); - } + if (cparse_cplusplus) { + const char *name = $6 ? Getattr($6, "name") : 0; + $$ = nested_forward_declaration($1, $2, 0, name, $6); } else { - Swig_warning(WARN_PARSE_UNNAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", $2); + if ($6) { + nested_new_struct($2, $5, $6); + } else { + Swig_warning(WARN_PARSE_UNNAMED_NESTED_CLASS, cparse_file, cparse_line, "Nested %s not currently supported (ignored).\n", $2); + } } } - Delete($4); + Delete($5); } -/* class name : base_list { }; declaration */ -/* This adds one shift/reduce. */ - - | storage_class cpptype idcolon COLON base_list LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}'); - } cpp_opt_declarators { - $$ = 0; - if (cplus_mode == CPLUS_PUBLIC) { - $$ = nested_forward_declaration($2, $3); - } - } /* This unfortunately introduces 4 shift/reduce conflicts, so instead the somewhat hacky nested_template is used for ignore nested template classes. */ /* From a07092b60c93de02beacf5c689693772bf499a6f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Nov 2009 07:16:26 +0000 Subject: [PATCH 250/352] Clarify typedef matching is typedef reduction only git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11757 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Typemaps.html | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index da4fdadc9..7a89a679a 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -1245,6 +1245,26 @@ is rather esoteric--there's little practical reason to write a typemap quite lik to confuse your coworkers even more.

      +

      +As a point of clarification, it is worth emphasizing that typedef matching is a typedef reduction process only, that is, SWIG does not search for every single possible typedef. +Given a type in a declaration, it will only reduce the type, it won't build it up looking for typedefs. +For example, given the type Struct, the typemap below will not be used for the aStruct parameter, +because Struct is fully reduced: +

      + +
      +
      +struct Struct {...};
      +typedef Struct StructTypedef;
      +
      +%typemap(in) StructTypedef { 
      +  ...
      +}
      +
      +void go(Struct aStruct);
      +
      +
      +

      10.3.3 Default typemaps

      From 1dd50f5ea8e75fe8035598661baf7a7535ee5de2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 26 Nov 2009 19:20:31 +0000 Subject: [PATCH 251/352] Fix %javaconst(1)/%csconst(1) for static const member variables to use the actual constant value if available git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11758 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 11 +++++++++++ Examples/test-suite/static_const_member.i | 6 ++++++ Source/Modules/csharp.cxx | 2 +- Source/Modules/java.cxx | 2 +- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index bed2fea3f..e7ee49381 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,17 @@ Version 1.3.41 (in progress) ============================ +2009-11-26: wsfulton + [Java, C#] Fix %javaconst(1)/%csconst(1) for static const member variables to + use the actual constant value if it is specified, rather than the C++ code to + access the member. + + %javaconst(1) EN; + %csconst(1) EN; + struct X { + static const int EN = 2; + }; + 2009-11-23: wsfulton C++ nested typedef classes can now be handled too, for example: struct Outer { diff --git a/Examples/test-suite/static_const_member.i b/Examples/test-suite/static_const_member.i index 99dc89bd1..a650b8936 100644 --- a/Examples/test-suite/static_const_member.i +++ b/Examples/test-suite/static_const_member.i @@ -5,6 +5,12 @@ %module static_const_member +#if SWIGJAVA +%javaconst(1) EN; +#elif SWIGCSHARP +%csconst(1) EN; +#endif + %inline %{ class X { diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index a752fb933..1fb57baf3 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1394,7 +1394,7 @@ public: enum_constant_flag = false; } else { // Alternative constant handling will use the C syntax to make a true C# constant and hope that it compiles as C# code - Printf(constants_code, "%s;\n", Getattr(n, "value")); + Printf(constants_code, "%s;\n", Getattr(n, "wrappedasconstant") ? Getattr(n, "staticmembervariableHandler:value") : Getattr(n, "value")); } // Emit the generated code to appropriate place diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index fd6c768c9..20a665726 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1426,7 +1426,7 @@ public: enum_constant_flag = false; } else { // Alternative constant handling will use the C syntax to make a true Java constant and hope that it compiles as Java code - Printf(constants_code, "%s;\n", Getattr(n, "value")); + Printf(constants_code, "%s;\n", Getattr(n, "wrappedasconstant") ? Getattr(n, "staticmembervariableHandler:value") : Getattr(n, "value")); } // Emit the generated code to appropriate place From d756b28611396a8b2ac2c2df05a88babf0a585b2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 26 Nov 2009 19:32:14 +0000 Subject: [PATCH 252/352] Correct %exception documentation so no memory is leaked - bug #2903761 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11759 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Customization.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index ec73e5460..82e1c411f 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -53,6 +53,21 @@ The %exception directive allows you to define a general purpose excepti handler. For example, you can specify the following:

      +
      +%exception {
      +    try {
      +        $action
      +    }
      +    catch (RangeError) {
      +        ... handle error ...
      +    }
      +}
      +
      + +

      +How the exception is handled depends on the target language, for example, Python: +

      +
       %exception {
           try {
      @@ -60,7 +75,7 @@ handler. For example, you can specify the following:
           }
           catch (RangeError) {
               PyErr_SetString(PyExc_IndexError,"index out-of-bounds");
      -        return NULL;
      +        SWIG_fail;
           }
       }
       
      From bf8ba3bf55f7b2e7d1cb1f18c637ee2e2b543f21 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 29 Nov 2009 01:29:26 +0000 Subject: [PATCH 253/352] Fix generated quoting when using %javaconst(1)/%csconst(1) for static const char member variables. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11760 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 10 ++++++++++ Examples/test-suite/static_const_member.i | 4 +++- Source/Modules/csharp.cxx | 9 ++++++++- Source/Modules/java.cxx | 9 ++++++++- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index e7ee49381..50c15c9e7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,16 @@ Version 1.3.41 (in progress) ============================ +2009-11-29: wsfulton + [Java, C#] Fix generated quoting when using %javaconst(1)/%csconst(1) for + static const char member variables. + + %javaconst(1) A; + %csconst(1) A; + struct X { + static const char A = 'A'; + }; + 2009-11-26: wsfulton [Java, C#] Fix %javaconst(1)/%csconst(1) for static const member variables to use the actual constant value if it is specified, rather than the C++ code to diff --git a/Examples/test-suite/static_const_member.i b/Examples/test-suite/static_const_member.i index a650b8936..126f86496 100644 --- a/Examples/test-suite/static_const_member.i +++ b/Examples/test-suite/static_const_member.i @@ -6,9 +6,10 @@ %module static_const_member #if SWIGJAVA -%javaconst(1) EN; +%javaconst(1) CHARTEST; #elif SWIGCSHARP %csconst(1) EN; +%csconst(1) CHARTEST; #endif %inline %{ @@ -18,6 +19,7 @@ public: static const int PN = 0; static const int CN = 1; static const int EN = 2; + static const char CHARTEST = 'A'; }; %} diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 1fb57baf3..82a9a629c 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1394,7 +1394,14 @@ public: enum_constant_flag = false; } else { // Alternative constant handling will use the C syntax to make a true C# constant and hope that it compiles as C# code - Printf(constants_code, "%s;\n", Getattr(n, "wrappedasconstant") ? Getattr(n, "staticmembervariableHandler:value") : Getattr(n, "value")); + if (Getattr(n, "wrappedasconstant")) { + if (SwigType_type(t) == T_CHAR) + Printf(constants_code, "\'%s\';\n", Getattr(n, "staticmembervariableHandler:value")); + else + Printf(constants_code, "%s;\n", Getattr(n, "staticmembervariableHandler:value")); + } else { + Printf(constants_code, "%s;\n", Getattr(n, "value")); + } } // Emit the generated code to appropriate place diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 20a665726..7fccab5e1 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1426,7 +1426,14 @@ public: enum_constant_flag = false; } else { // Alternative constant handling will use the C syntax to make a true Java constant and hope that it compiles as Java code - Printf(constants_code, "%s;\n", Getattr(n, "wrappedasconstant") ? Getattr(n, "staticmembervariableHandler:value") : Getattr(n, "value")); + if (Getattr(n, "wrappedasconstant")) { + if (SwigType_type(t) == T_CHAR) + Printf(constants_code, "\'%s\';\n", Getattr(n, "staticmembervariableHandler:value")); + else + Printf(constants_code, "%s;\n", Getattr(n, "staticmembervariableHandler:value")); + } else { + Printf(constants_code, "%s;\n", Getattr(n, "value")); + } } // Emit the generated code to appropriate place From b9817010fb597babea511adee712cf8d379f219c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 29 Nov 2009 01:50:21 +0000 Subject: [PATCH 254/352] add in missing line since last commit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11761 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/static_const_member.i | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/static_const_member.i b/Examples/test-suite/static_const_member.i index 126f86496..3db60b4c2 100644 --- a/Examples/test-suite/static_const_member.i +++ b/Examples/test-suite/static_const_member.i @@ -6,6 +6,7 @@ %module static_const_member #if SWIGJAVA +%javaconst(1) EN; %javaconst(1) CHARTEST; #elif SWIGCSHARP %csconst(1) EN; From 2bd190dbf1cd79c5c4072d3b0891054c6b03ff1e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 2 Dec 2009 00:01:31 +0000 Subject: [PATCH 255/352] Revert support for %extend and memberin typemaps added in swig-1.3.39. The memberin typemaps are ignored again for member variables within a %extend block. Documentation inconsistency reported by Torsten Landschoff. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11762 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++ Doc/Manual/SWIG.html | 10 ++--- Examples/test-suite/common.mk | 1 + Examples/test-suite/memberin_extend.i | 15 ++++++- Examples/test-suite/memberin_extend_c.i | 25 +++++++++++ .../python/memberin_extend_c_runme.py | 6 +++ Source/Modules/lang.cxx | 45 +++++++++---------- Source/Swig/cwrap.c | 14 +++--- Source/Swig/swig.h | 2 +- 9 files changed, 85 insertions(+), 38 deletions(-) create mode 100644 Examples/test-suite/memberin_extend_c.i create mode 100644 Examples/test-suite/python/memberin_extend_c_runme.py diff --git a/CHANGES.current b/CHANGES.current index 50c15c9e7..d5b5e9670 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.41 (in progress) ============================ +2009-12-01: wsfulton + Revert support for %extend and memberin typemaps added in swig-1.3.39. The + memberin typemaps are ignored again for member variables within a %extend block. + Documentation inconsistency reported by Torsten Landschoff. + 2009-11-29: wsfulton [Java, C#] Fix generated quoting when using %javaconst(1)/%csconst(1) for static const char member variables. diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index dd1b22095..8818a6c60 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -2493,7 +2493,7 @@ instead of a method. To do this, you might write some code like this: // Now supply the implementation of the Vector_magnitude_get function %{ const double Vector_magnitude_get(Vector *v) { - return (const double) return sqrt(v->x*v->x+v->y*v->y+v->z*v->z); + return (const double) sqrt(v->x*v->x+v->y*v->y+v->z*v->z); } %} @@ -2512,10 +2512,10 @@ For example, consider this interface:
      -struct Person {
      +typedef struct {
          char name[50];
          ...
      -}
      +} Person;
       
      @@ -2527,12 +2527,12 @@ as follows to change this:
      -struct Person {
      +typedef struct {
           %extend {
              char *name;
           }
       ...
      -}
      +} Person;
       
       // Specific implementation of set/get functions
       %{
      diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
      index f9e06c0c4..bb72e4988 100644
      --- a/Examples/test-suite/common.mk
      +++ b/Examples/test-suite/common.mk
      @@ -458,6 +458,7 @@ C_TEST_CASES += \
       	li_cpointer \
       	li_math \
       	long_long \
      +	memberin_extend_c \
       	name \
       	nested \
       	nested_structs \
      diff --git a/Examples/test-suite/memberin_extend.i b/Examples/test-suite/memberin_extend.i
      index f20617b66..94d2cab3f 100644
      --- a/Examples/test-suite/memberin_extend.i
      +++ b/Examples/test-suite/memberin_extend.i
      @@ -12,8 +12,19 @@ struct ExtendMe {
       %{
       #include 
       std::map ExtendMeStringMap;
      -#define ExtendMe_thing_set(self_, val_) ExtendMeStringMap[self_]
      -#define ExtendMe_thing_get(self_) ExtendMeStringMap[self_]
      +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 {
      diff --git a/Examples/test-suite/memberin_extend_c.i b/Examples/test-suite/memberin_extend_c.i
      new file mode 100644
      index 000000000..e0c2f6333
      --- /dev/null
      +++ b/Examples/test-suite/memberin_extend_c.i
      @@ -0,0 +1,25 @@
      +%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;
      +    }
      +} Person;
      +
      +/* Specific implementation of set/get functions */
      +%{
      +char *Person_name_get(Person *p) {
      +   return p->name;
      +}
      +void Person_name_set(Person *p, char *val) {
      +   strncpy(p->name,val,50);
      +}
      +%}
      diff --git a/Examples/test-suite/python/memberin_extend_c_runme.py b/Examples/test-suite/python/memberin_extend_c_runme.py
      new file mode 100644
      index 000000000..af84535eb
      --- /dev/null
      +++ b/Examples/test-suite/python/memberin_extend_c_runme.py
      @@ -0,0 +1,6 @@
      +import memberin_extend_c
      +
      +t = memberin_extend_c.Person()
      +t.name = "some name"
      +if t.name != "some name":
      +  raise RuntimeError("some name wrong")
      diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
      index e58f2b022..971b56ec1 100644
      --- a/Source/Modules/lang.cxx
      +++ b/Source/Modules/lang.cxx
      @@ -1407,39 +1407,36 @@ int Language::membervariableHandler(Node *n) {
       	  target = NewStringf("%s->%s", pname, name);
       	  Delete(pname);
       	}
      -      } else {
      -	 target = NewStringf("$extendgetcall"); // member variable access expanded later
      +	tm = Swig_typemap_lookup("memberin", n, target, 0);
             }
      -      tm = Swig_typemap_lookup("memberin", n, target, 0);
             int flags = Extend | SmartPointer | use_naturalvar_mode(n);
             if (is_non_virtual_protected_access(n))
               flags = flags | CWRAP_ALL_PROTECTED_ACCESS;
       
      -      String *call = 0;
      -      Swig_MembersetToFunction(n, ClassType, flags, &call);
      +      Swig_MembersetToFunction(n, ClassType, flags);
             Setattr(n, "memberset", "1");
      +      if (!Extend) {
      +	/* Check for a member in typemap here */
       
      -      if (!tm) {
      -	if (SwigType_isarray(type)) {
      -	  Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0));
      -	  make_set_wrapper = 0;
      +	if (!tm) {
      +	  if (SwigType_isarray(type)) {
      +	    Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0));
      +	    make_set_wrapper = 0;
      +	  }
      +	} else {
      +	  String *pname0 = Swig_cparm_name(0, 0);
      +	  String *pname1 = Swig_cparm_name(0, 1);
      +	  Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
      +	  Replace(tm, "$target", target, DOH_REPLACE_ANY);
      +	  Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
      +	  Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
      +	  Setattr(n, "wrap:action", tm);
      +	  Delete(tm);
      +	  Delete(pname0);
      +	  Delete(pname1);
       	}
      -      } else {
      -	String *pname0 = Swig_cparm_name(0, 0);
      -	String *pname1 = Swig_cparm_name(0, 1);
      -	Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
      -	Replace(tm, "$target", target, DOH_REPLACE_ANY);
      -	Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
      -	Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
      -	Replace(tm, "$extendgetcall", call, DOH_REPLACE_ANY);
      -	Setattr(n, "wrap:action", tm);
      -	Delete(tm);
      -	Delete(pname0);
      -	Delete(pname1);
      +	Delete(target);
             }
      -      Delete(call);
      -      Delete(target);
      -
             if (make_set_wrapper) {
       	Setattr(n, "sym:name", mrename_set);
       	functionWrapper(n);
      diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
      index 121ea150a..7b2646b0e 100644
      --- a/Source/Swig/cwrap.c
      +++ b/Source/Swig/cwrap.c
      @@ -1207,7 +1207,7 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags)
        * This function creates a C wrapper for setting a structure member.
        * ----------------------------------------------------------------------------- */
       
      -int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **call) {
      +int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
         String *name;
         ParmList *parms;
         Parm *p;
      @@ -1255,21 +1255,23 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **cal
         Delete(p);
       
         if (flags & CWRAP_EXTEND) {
      +    String *call;
           String *cres;
           String *code = Getattr(n, "code");
           if (code) {
             /* I don't think this ever gets run - WSF */
             Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, "self");
           }
      -    *call = Swig_cfunction_call(mangled, parms);
      -    cres = NewStringf("%s;", *call);
      +    call = Swig_cfunction_call(mangled, parms);
      +    cres = NewStringf("%s;", call);
           Setattr(n, "wrap:action", cres);
      +    Delete(call);
           Delete(cres);
         } else {
      -    String *cres;
      -    *call = Swig_cmemberset_call(name, type, self, varcref);
      -    cres = NewStringf("%s;", *call);
      +    String *call = Swig_cmemberset_call(name, type, self, varcref);
      +    String *cres = NewStringf("%s;", call);
           Setattr(n, "wrap:action", cres);
      +    Delete(call);
           Delete(cres);
         }
         Setattr(n, "type", void_type);
      diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
      index 33f977b52..2c2d4aa3b 100644
      --- a/Source/Swig/swig.h
      +++ b/Source/Swig/swig.h
      @@ -348,7 +348,7 @@ extern int        ParmList_is_compactdefargs(ParmList *p);
         extern int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director);
         extern int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags);
         extern int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags);
      -  extern int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **call);
      +  extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
         extern int Swig_MembergetToFunction(Node *n, String *classname, int flags);
         extern int Swig_VargetToFunction(Node *n, int flags);
         extern int Swig_VarsetToFunction(Node *n, int flags);
      
      From 2c74fbf9e41684fde01d6b2a99d0c1655e889fa2 Mon Sep 17 00:00:00 2001
      From: Olly Betts 
      Date: Wed, 2 Dec 2009 13:02:38 +0000
      Subject: [PATCH 256/352] [PHP] Fix warning and rename of reserved class name
       to be case insensitive.
      
      git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11763 626c5289-ae23-0410-ae9c-e8d60b6d4f22
      ---
       CHANGES.current                           |   3 +
       Examples/test-suite/php_namewarn_rename.i |   8 +-
       Lib/php/phpkw.swg                         | 200 +++++++++++-----------
       3 files changed, 110 insertions(+), 101 deletions(-)
      
      diff --git a/CHANGES.current b/CHANGES.current
      index d5b5e9670..d81907f2c 100644
      --- a/CHANGES.current
      +++ b/CHANGES.current
      @@ -1,6 +1,9 @@
       Version 1.3.41 (in progress)
       ============================
       
      +2009-12-02: olly
      +	    [PHP] Fix warning and rename of reserved class name to be case insensitive.
      +
       2009-12-01: wsfulton
                   Revert support for %extend and memberin typemaps added in swig-1.3.39. The
       	    memberin typemaps are ignored again for member variables within a %extend block.
      diff --git a/Examples/test-suite/php_namewarn_rename.i b/Examples/test-suite/php_namewarn_rename.i
      index cebe93f02..e3447a9c4 100644
      --- a/Examples/test-suite/php_namewarn_rename.i
      +++ b/Examples/test-suite/php_namewarn_rename.i
      @@ -2,19 +2,25 @@
       
       #ifdef SWIGPHP
       %warnfilter(SWIGWARN_PARSE_KEYWORD) Empty();
      -// FIXME: this doesn't work for me:
       %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/Lib/php/phpkw.swg b/Lib/php/phpkw.swg
      index a5f410bc5..5e60583cb 100644
      --- a/Lib/php/phpkw.swg
      +++ b/Lib/php/phpkw.swg
      @@ -5,13 +5,13 @@
        * phpkw.swg
        * ----------------------------------------------------------------------------- */
       
      -#define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",$isclass,rename="c_%s")  `x`
      +#define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",rename="c_%s") `x`
       
      -#define PHPCN(x) %keywordwarn("'" `x` "' is a PHP reserved class name, class renamed as 'c_" `x` "'",%$isclass,rename="c_%s") `x`
      +#define PHPCN(x) %keywordwarn("'" `x` "' is a PHP reserved class name, class renamed as 'c_" `x` "'",%$isclass,sourcefmt="%(lower)s",rename="c_%s") `x`
       
      -#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP",sourcefmt="%(lower)s")  `x`
      -#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP")  "::" `x`
      -#define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s")  `x`
      +#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP",sourcefmt="%(lower)s") `x`
      +#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP") "::" `x`
      +#define PHPFN(x) %keywordwarn("'" `x` "' is a PHP built-in function, renamed as 'c_" `x` "'",sourcefmt="%(lower)s",%$isfunction,%$not %$ismember,rename="c_%s") `x`
       
       /*
          From
      @@ -355,105 +355,105 @@ PHPBN2(E_STRICT);
       PHPBN2(__COMPILER_HALT_OFFSET__);
       
       /* Class names reserved by PHP */
      -PHPCN(stdClass);
      -PHPCN(__PHP_Incomplete_Class);
      -PHPCN(Directory);
      -
      +/* case insensitive */
      +PHPCN(stdclass);
      +PHPCN(__php_incomplete_class);
      +PHPCN(directory);
       /* Added in PHP5 (this list apparently depends which extensions you load by default). */
       PHPCN(parent);
       PHPCN(self);
      -PHPCN(Exception);
      +PHPCN(exception);
       PHPCN(php_user_filter);
      -PHPCN(ErrorException);
      -PHPCN(XMLWriter);
      -PHPCN(LibXMLError);
      -PHPCN(SimpleXMLElement);
      -PHPCN(SoapClient);
      -PHPCN(SoapVar);
      -PHPCN(SoapServer);
      -PHPCN(SoapFault);
      -PHPCN(SoapParam);
      -PHPCN(SoapHeader);
      -PHPCN(RecursiveIteratorIterator);
      -PHPCN(FilterIterator);
      -PHPCN(RecursiveFilterIterator);
      -PHPCN(ParentIterator);
      -PHPCN(LimitIterator);
      -PHPCN(CachingIterator);
      -PHPCN(RecursiveCachingIterator);
      -PHPCN(IteratorIterator);
      -PHPCN(NoRewindIterator);
      -PHPCN(AppendIterator);
      -PHPCN(InfiniteIterator);
      -PHPCN(EmptyIterator);
      -PHPCN(ArrayObject);
      -PHPCN(ArrayIterator);
      -PHPCN(RecursiveArrayIterator);
      -PHPCN(SplFileInfo);
      -PHPCN(DirectoryIterator);
      -PHPCN(RecursiveDirectoryIterator);
      -PHPCN(SplFileObject);
      -PHPCN(SplTempFileObject);
      -PHPCN(SimpleXMLIterator);
      -PHPCN(LogicException);
      -PHPCN(BadFunctionCallException);
      -PHPCN(BadMethodCallException);
      -PHPCN(DomainException);
      -PHPCN(InvalidArgumentException);
      -PHPCN(LengthException);
      -PHPCN(OutOfRangeException);
      -PHPCN(RuntimeException);
      -PHPCN(OutOfBoundsException);
      -PHPCN(OverflowException);
      -PHPCN(RangeException);
      -PHPCN(UnderflowException);
      -PHPCN(UnexpectedValueException);
      -PHPCN(SplObjectStorage);
      -PHPCN(ReflectionException);
      -PHPCN(Reflection);
      -PHPCN(ReflectionFunction);
      -PHPCN(ReflectionParameter);
      -PHPCN(ReflectionMethod);
      -PHPCN(ReflectionClass);
      -PHPCN(ReflectionObject);
      -PHPCN(ReflectionProperty);
      -PHPCN(ReflectionExtension);
      -PHPCN(DOMException);
      -PHPCN(DOMStringList);
      -PHPCN(DOMNameList);
      -PHPCN(DOMImplementationList);
      -PHPCN(DOMImplementationSource);
      -PHPCN(DOMImplementation);
      -PHPCN(DOMNode);
      -PHPCN(DOMNameSpaceNode);
      -PHPCN(DOMDocumentFragment);
      -PHPCN(DOMDocument);
      -PHPCN(DOMNodeList);
      -PHPCN(DOMNamedNodeMap);
      -PHPCN(DOMCharacterData);
      -PHPCN(DOMAttr);
      -PHPCN(DOMElement);
      -PHPCN(DOMText);
      -PHPCN(DOMComment);
      -PHPCN(DOMTypeinfo);
      -PHPCN(DOMUserDataHandler);
      -PHPCN(DOMDomError);
      -PHPCN(DOMErrorHandler);
      -PHPCN(DOMLocator);
      -PHPCN(DOMConfiguration);
      -PHPCN(DOMCdataSection);
      -PHPCN(DOMDocumentType);
      -PHPCN(DOMNotation);
      -PHPCN(DOMEntity);
      -PHPCN(DOMEntityReference);
      -PHPCN(DOMProcessingInstruction);
      -PHPCN(DOMStringExtend);
      -PHPCN(DOMXPath);
      -PHPCN(XMLReader);
      -PHPCN(SQLiteDatabase);
      -PHPCN(SQLiteResult);
      -PHPCN(SQLiteUnbuffered);
      -PHPCN(SQLiteException);
      +PHPCN(errorexception);
      +PHPCN(xmlwriter);
      +PHPCN(libxmlerror);
      +PHPCN(simplexmlelement);
      +PHPCN(soapclient);
      +PHPCN(soapvar);
      +PHPCN(soapserver);
      +PHPCN(soapfault);
      +PHPCN(soapparam);
      +PHPCN(soapheader);
      +PHPCN(recursiveiteratoriterator);
      +PHPCN(filteriterator);
      +PHPCN(recursivefilteriterator);
      +PHPCN(parentiterator);
      +PHPCN(limititerator);
      +PHPCN(cachingiterator);
      +PHPCN(recursivecachingiterator);
      +PHPCN(iteratoriterator);
      +PHPCN(norewinditerator);
      +PHPCN(appenditerator);
      +PHPCN(infiniteiterator);
      +PHPCN(emptyiterator);
      +PHPCN(arrayobject);
      +PHPCN(arrayiterator);
      +PHPCN(recursivearrayiterator);
      +PHPCN(splfileinfo);
      +PHPCN(directoryiterator);
      +PHPCN(recursivedirectoryiterator);
      +PHPCN(splfileobject);
      +PHPCN(spltempfileobject);
      +PHPCN(simplexmliterator);
      +PHPCN(logicexception);
      +PHPCN(badfunctioncallexception);
      +PHPCN(badmethodcallexception);
      +PHPCN(domainexception);
      +PHPCN(invalidargumentexception);
      +PHPCN(lengthexception);
      +PHPCN(outofrangeexception);
      +PHPCN(runtimeexception);
      +PHPCN(outofboundsexception);
      +PHPCN(overflowexception);
      +PHPCN(rangeexception);
      +PHPCN(underflowexception);
      +PHPCN(unexpectedvalueexception);
      +PHPCN(splobjectstorage);
      +PHPCN(reflectionexception);
      +PHPCN(reflection);
      +PHPCN(reflectionfunction);
      +PHPCN(reflectionparameter);
      +PHPCN(reflectionmethod);
      +PHPCN(reflectionclass);
      +PHPCN(reflectionobject);
      +PHPCN(reflectionproperty);
      +PHPCN(reflectionextension);
      +PHPCN(domexception);
      +PHPCN(domstringlist);
      +PHPCN(domnamelist);
      +PHPCN(domimplementationlist);
      +PHPCN(domimplementationsource);
      +PHPCN(domimplementation);
      +PHPCN(domnode);
      +PHPCN(domnamespacenode);
      +PHPCN(domdocumentfragment);
      +PHPCN(domdocument);
      +PHPCN(domnodelist);
      +PHPCN(domnamednodemap);
      +PHPCN(domcharacterdata);
      +PHPCN(domattr);
      +PHPCN(domelement);
      +PHPCN(domtext);
      +PHPCN(domcomment);
      +PHPCN(domtypeinfo);
      +PHPCN(domuserdatahandler);
      +PHPCN(domdomerror);
      +PHPCN(domerrorhandler);
      +PHPCN(domlocator);
      +PHPCN(domconfiguration);
      +PHPCN(domcdatasection);
      +PHPCN(domdocumenttype);
      +PHPCN(domnotation);
      +PHPCN(domentity);
      +PHPCN(domentityreference);
      +PHPCN(domprocessinginstruction);
      +PHPCN(domstringextend);
      +PHPCN(domxpath);
      +PHPCN(xmlreader);
      +PHPCN(sqlitedatabase);
      +PHPCN(sqliteresult);
      +PHPCN(sqliteunbuffered);
      +PHPCN(sqliteexception);
       
       /* Built-in PHP functions (incomplete). */
       PHPFN(cos);
      
      From 09a801dd9e461f571e89c12efa02a6c908f8a77d Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Wed, 2 Dec 2009 22:16:48 +0000
      Subject: [PATCH 257/352] Change %extend example which said that char arrays
       were problematic to wrap, when in fact they are not
      
      git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11764 626c5289-ae23-0410-ae9c-e8d60b6d4f22
      ---
       Doc/Manual/SWIG.html                          | 44 ++++++++++++-------
       Examples/test-suite/memberin_extend.i         |  2 +-
       Examples/test-suite/memberin_extend_c.i       | 29 ++++++++----
       .../python/memberin_extend_c_runme.py         |  6 +--
       4 files changed, 53 insertions(+), 28 deletions(-)
      
      diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
      index 8818a6c60..c17add4c5 100644
      --- a/Doc/Manual/SWIG.html
      +++ b/Doc/Manual/SWIG.html
      @@ -2506,41 +2506,53 @@ of the object.
       

      -A similar technique can also be used to work with problematic data members. +A similar technique can also be used to work with data members that you want to process. For example, consider this interface:

       typedef struct {
      -   char name[50];
      -   ...
      +  char name[50];
      +  ...
       } Person;
       

      -By default, the name attribute is read-only because SWIG does not -normally know how to modify arrays. However, you can rewrite the interface -as follows to change this: +Say you wanted to ensure name was always upper case, you can rewrite +the interface as follows to ensure this occurs whenever a name is read or written to:

       typedef struct {
      -    %extend {
      -       char *name;
      -    }
      -...
      +  %extend {
      +    char name[50];
      +  }
      +  ...
       } Person;
       
      -// Specific implementation of set/get functions
       %{
      -char *Person_name_get(Person *p) {
      -   return p->name;
      +#include <string.h>
      +#include <ctype.h>
      +
      +void make_upper(char *name) {
      +  char *c;
      +  for (c = name; *c; ++c)
      +    *c = (char)toupper((int)*c);
       }
      +
      +/* Specific implementation of set/get functions forcing capitalization */
      +
      +char *Person_name_get(Person *p) {
      +  make_upper(p->name);
      +  return p->name;
      +}
      +
       void Person_name_set(Person *p, char *val) {
      -   strncpy(p->name,val,50);
      +  strncpy(p->name,val,50);
      +  make_upper(p->name);
       }
       %}
       
      @@ -2550,7 +2562,7 @@ void Person_name_set(Person *p, char *val) { Finally, it should be stressed that even though %extend can be used to add new data members, these new members can not require the allocation of additional storage in the object (e.g., their values must -be entirely synthesized from existing attributes of the structure). +be entirely synthesized from existing attributes of the structure or obtained elsewhere).

      @@ -2633,7 +2645,7 @@ $o->{intRep}->{ivalue} = 7 # Change value of o.intRep.ivalue

      -If you have a lot nested structure declarations, it is +If you have a lot of nested structure declarations, it is advisable to double-check them after running SWIG. Although, there is a good chance that they will work, you may have to modify the interface file in certain cases. diff --git a/Examples/test-suite/memberin_extend.i b/Examples/test-suite/memberin_extend.i index 94d2cab3f..c6eb10526 100644 --- a/Examples/test-suite/memberin_extend.i +++ b/Examples/test-suite/memberin_extend.i @@ -1,6 +1,6 @@ %module memberin_extend -// Tests memberin typemap. The default char * memberin typemap will be used. +// Tests memberin typemap is not used for %extend. // The test extends the struct with a pseudo member variable %inline %{ diff --git a/Examples/test-suite/memberin_extend_c.i b/Examples/test-suite/memberin_extend_c.i index e0c2f6333..0599e65a0 100644 --- a/Examples/test-suite/memberin_extend_c.i +++ b/Examples/test-suite/memberin_extend_c.i @@ -4,22 +4,35 @@ %{ typedef struct { - char name[50]; + char name[50]; } Person; %} typedef struct { - %extend { - char *name; - } + %extend { + char name[50]; + } } Person; -/* Specific implementation of set/get functions */ %{ -char *Person_name_get(Person *p) { - return p->name; +#include +#include + +void make_upper(char *name) { + char *c; + for (c = name; *c; ++c) + *c = (char)toupper((int)*c); } + +/* Specific implementation of set/get functions forcing capitalization */ + +char *Person_name_get(Person *p) { + make_upper(p->name); + return p->name; +} + void Person_name_set(Person *p, char *val) { - strncpy(p->name,val,50); + strncpy(p->name,val,50); + make_upper(p->name); } %} diff --git a/Examples/test-suite/python/memberin_extend_c_runme.py b/Examples/test-suite/python/memberin_extend_c_runme.py index af84535eb..314761f89 100644 --- a/Examples/test-suite/python/memberin_extend_c_runme.py +++ b/Examples/test-suite/python/memberin_extend_c_runme.py @@ -1,6 +1,6 @@ import memberin_extend_c t = memberin_extend_c.Person() -t.name = "some name" -if t.name != "some name": - raise RuntimeError("some name wrong") +t.name = "Fred Bloggs" +if t.name != "FRED BLOGGS": + raise RuntimeError("name wrong") From 52bdfa30973c7912ae5bf31318f8c578a17db76b Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Dec 2009 01:29:45 +0000 Subject: [PATCH 258/352] Add input typemaps for long long and unsigned long long for PHP. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11765 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/php.swg | 4 ++++ Lib/php/utils.i | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/Lib/php/php.swg b/Lib/php/php.swg index a604b035b..de8904cb0 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -55,6 +55,10 @@ %pass_by_val(long, CONVERT_INT_IN); %pass_by_val(unsigned long, CONVERT_INT_IN); +%pass_by_val(signed long long, CONVERT_LONG_LONG_IN); +%pass_by_val(long long, CONVERT_LONG_LONG_IN); +%pass_by_val(unsigned long long, CONVERT_UNSIGNED_LONG_LONG_IN); + %pass_by_val(signed char, CONVERT_INT_IN); %pass_by_val(char, CONVERT_CHAR_IN); %pass_by_val(unsigned char, CONVERT_INT_IN); diff --git a/Lib/php/utils.i b/Lib/php/utils.i index 166941585..07ac96900 100644 --- a/Lib/php/utils.i +++ b/Lib/php/utils.i @@ -9,6 +9,42 @@ lvar = (t) Z_LVAL_PP(invar); %enddef +%define CONVERT_LONG_LONG_IN(lvar,t,invar) + switch ((*(invar))->type) { + case IS_DOUBLE: + lvar = (t) (*(invar))->value.dval; + break; + case IS_STRING: { + char * endptr; + errno = 0; + lvar = (t) strtoll((*(invar))->value.str.val, &endptr, 10); + if (*endptr && !errno) break; + /* FALL THRU */ + } + default: + convert_to_long_ex(invar); + lvar = (t) (*(invar))->value.lval; + } +%enddef + +%define CONVERT_UNSIGNED_LONG_LONG_IN(lvar,t,invar) + switch ((*(invar))->type) { + case IS_DOUBLE: + lvar = (t) (*(invar))->value.dval; + break; + case IS_STRING: { + char * endptr; + errno = 0; + lvar = (t) strtoull((*(invar))->value.str.val, &endptr, 10); + if (*endptr && !errno) break; + /* FALL THRU */ + } + default: + convert_to_long_ex(invar); + lvar = (t) (*(invar))->value.lval; + } +%enddef + %define CONVERT_INT_OUT(lvar,invar) lvar = (t) Z_LVAL_PP(invar); %enddef From d6984c5253ee6115f51f9e217a98dcc8981f7ff1 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Dec 2009 04:48:54 +0000 Subject: [PATCH 259/352] [PHP] Add typemaps for long long and unsigned long long. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11766 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/php/php.swg | 2 ++ Lib/php/typemaps.i | 32 ++++++++++++++++++++++++++------ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index d81907f2c..60b19cf3e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.41 (in progress) ============================ +2009-12-03: olly + [PHP] Add typemaps for long long and unsigned long long. + 2009-12-02: olly [PHP] Fix warning and rename of reserved class name to be case insensitive. diff --git a/Lib/php/php.swg b/Lib/php/php.swg index de8904cb0..8deb85254 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -361,6 +361,8 @@ %php_typecheck(unsigned short,SWIG_TYPECHECK_UINT16,IS_LONG) %php_typecheck(long,SWIG_TYPECHECK_INT64,IS_LONG) %php_typecheck(unsigned long,SWIG_TYPECHECK_UINT64,IS_LONG) +%php_typecheck(long long,SWIG_TYPECHECK_INT64,IS_LONG) +%php_typecheck(unsigned long long,SWIG_TYPECHECK_UINT64,IS_LONG) %php_typecheck(signed char,SWIG_TYPECHECK_INT8,IS_LONG) %php_typecheck(unsigned char,SWIG_TYPECHECK_UINT8,IS_LONG) %php_typecheck(size_t,SWIG_TYPECHECK_INT16,IS_LONG) diff --git a/Lib/php/typemaps.i b/Lib/php/typemaps.i index 7af301d0d..cc2341b19 100644 --- a/Lib/php/typemaps.i +++ b/Lib/php/typemaps.i @@ -112,9 +112,7 @@ int_typemap(long long); } %typemap(in) TYPE *REFERENCE (long long lvalue) %{ - // FIXME won't work for values which don't fit in a long... - convert_to_long_ex($input); - lvalue = (long long) (*$input)->value.lval; + CONVERT_LONG_LONG_IN(lvalue, long long, $input) $1 = &lvalue; %} %typemap(argout) long long *REFERENCE @@ -128,6 +126,17 @@ int_typemap(long long); ZVAL_STRING((*$arg), temp, 1); } %} +%typemap(argout) long long &OUTPUT +%{ + if ((long long)LONG_MIN <= *arg$argnum && *arg$argnum <= (long long)LONG_MAX) { + ($result)->value.lval = (long)(*arg$argnum); + ($result)->type = IS_LONG; + } else { + char temp[256]; + sprintf(temp, "%lld", *arg$argnum); + ZVAL_STRING($result, temp, 1); + } +%} int_typemap(unsigned long long); %typemap(argout,fragment="t_output_helper") unsigned long long *OUTPUT { @@ -144,9 +153,7 @@ int_typemap(unsigned long long); } %typemap(in) TYPE *REFERENCE (unsigned long long lvalue) %{ - // FIXME won't work for values which don't fit in a long... - convert_to_long_ex($input); - lvalue = (unsigned long long) (*$input)->value.lval; + CONVERT_UNSIGNED_LONG_LONG_IN(lvalue, unsigned long long, $input) $1 = &lvalue; %} %typemap(argout) unsigned long long *REFERENCE @@ -160,6 +167,17 @@ int_typemap(unsigned long long); ZVAL_STRING((*$arg), temp, 1); } %} +%typemap(argout) unsigned long long &OUTPUT +%{ + if (*arg$argnum <= (unsigned long long)LONG_MAX) { + ($result)->value.lval = (long)(*arg$argnum); + ($result)->type = IS_LONG; + } else { + char temp[256]; + sprintf(temp, "%llu", *arg$argnum); + ZVAL_STRING($result, temp, 1); + } +%} %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; @@ -181,11 +199,13 @@ int_typemap(unsigned long long); %typemap(in) short &INOUT = short *INPUT; %typemap(in) long &INOUT = long *INPUT; %typemap(in) long long &INOUT = long long *INPUT; +%typemap(in) long long &INPUT = long long *INPUT; %typemap(in) unsigned &INOUT = unsigned *INPUT; %typemap(in) unsigned short &INOUT = unsigned short *INPUT; %typemap(in) unsigned long &INOUT = unsigned long *INPUT; %typemap(in) unsigned char &INOUT = unsigned char *INPUT; %typemap(in) unsigned long long &INOUT = unsigned long long *INPUT; +%typemap(in) unsigned long long &INPUT = unsigned long long *INPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT= double *OUTPUT; From d2773541679f8887df7faa6927b688414306d886 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Dec 2009 05:21:48 +0000 Subject: [PATCH 260/352] Add long long and unsigned long long const reference typemaps. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11767 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/php/primitive_ref_runme.php | 6 +-- Lib/php/php.swg | 46 +++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/php/primitive_ref_runme.php b/Examples/test-suite/php/primitive_ref_runme.php index 6a5a3f43d..ab23fb1cc 100644 --- a/Examples/test-suite/php/primitive_ref_runme.php +++ b/Examples/test-suite/php/primitive_ref_runme.php @@ -17,9 +17,9 @@ 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"); -//check::equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longlong failed"); -//check::equal(ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed"); -printf("TODO: long long and unsigned long long const reference typemaps\n"); +check::equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longlong failed"); +# 0xF23456789ABCDEF0 won't fit in a long, so PHP makes it a double, but SWIG opts to return it as a string. +check::equal((double)ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed"); check::done(); ?> diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 8deb85254..704b6c616 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -198,6 +198,29 @@ ZVAL_LONG(return_value,$1); } +%typemap(out) long long +%{ + if ((long long)LONG_MIN <= $1 && $1 <= (long long)LONG_MAX) { + return_value->value.lval = (long)($1); + return_value->type = IS_LONG; + } else { + char temp[256]; + sprintf(temp, "%lld", $1); + ZVAL_STRING(return_value, temp, 1); + } +%} +%typemap(out) unsigned long long +%{ + if ($1 <= (unsigned long long)LONG_MAX) { + return_value->value.lval = (long)($1); + return_value->type = IS_LONG; + } else { + char temp[256]; + sprintf(temp, "%llu", $1); + ZVAL_STRING(return_value, temp, 1); + } +%} + %typemap(out) const int &, const unsigned int &, const short &, @@ -213,6 +236,29 @@ ZVAL_LONG(return_value,*$1); } +%typemap(out) const long long & +%{ + if ((long long)LONG_MIN <= *$1 && *$1 <= (long long)LONG_MAX) { + return_value->value.lval = (long)(*$1); + return_value->type = IS_LONG; + } else { + char temp[256]; + sprintf(temp, "%lld", *$1); + ZVAL_STRING(return_value, temp, 1); + } +%} +%typemap(out) const unsigned long long & +%{ + if (*$1 <= (unsigned long long)LONG_MAX) { + return_value->value.lval = (long)(*$1); + return_value->type = IS_LONG; + } else { + char temp[256]; + sprintf(temp, "%llu", *$1); + ZVAL_STRING(return_value, temp, 1); + } +%} + %typemap(directorin) int, unsigned int, short, From 67bbac487280b65664255379a4988d1d5056672c Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Dec 2009 12:59:59 +0000 Subject: [PATCH 261/352] Add PHP typemaps for pointer to method. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11768 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++-- Lib/php/const.i | 3 +++ Lib/php/globalvar.i | 29 ++++++++++++++++++++++++++++- Lib/php/php.swg | 17 +++++++++++++++++ Lib/php/phpinit.swg | 1 + Lib/php/phprun.swg | 9 +++++++++ 6 files changed, 62 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 60b19cf3e..1c39df098 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,10 +2,12 @@ Version 1.3.41 (in progress) ============================ 2009-12-03: olly - [PHP] Add typemaps for long long and unsigned long long. + [PHP] Add typemaps for long long and unsigned long long, and for + pointer to method. 2009-12-02: olly - [PHP] Fix warning and rename of reserved class name to be case insensitive. + [PHP] Fix warning and rename of reserved class name to be case + insensitive. 2009-12-01: wsfulton Revert support for %extend and memberin typemaps added in swig-1.3.39. The diff --git a/Lib/php/const.i b/Lib/php/const.i index 6ddd403d0..d2d1c75bd 100644 --- a/Lib/php/const.i +++ b/Lib/php/const.i @@ -51,3 +51,6 @@ c.module_number = module_number; zend_register_constant( &c TSRMLS_CC ); } + +/* Handled as a global variable. */ +%typemap(consttab) SWIGTYPE (CLASS::*) ""; diff --git a/Lib/php/globalvar.i b/Lib/php/globalvar.i index df8cfade7..be20a96bc 100644 --- a/Lib/php/globalvar.i +++ b/Lib/php/globalvar.i @@ -105,6 +105,16 @@ zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&z_var, sizeof(zval *), NULL); } +%typemap(varinit) SWIGTYPE (CLASS::*) +{ + void * p = emalloc(sizeof($1)); + memcpy(p, &$1, sizeof($1)); + zval * resource; + MAKE_STD_ZVAL(resource); + ZEND_REGISTER_RESOURCE(resource, p, le_member_ptr); + zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL); +} + %typemap(varin) int, unsigned int, short, unsigned short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE { zval **z_var; @@ -216,6 +226,15 @@ $1 = ($1_ltype)_temp; } +%typemap(varin) SWIGTYPE (CLASS::*) +{ + zval **z_var; + + zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var); + void * p = (void*)zend_fetch_resource(*z_var TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, le_member_ptr); + memcpy(&$1, p, sizeof($1)); +} + %typemap(varout) int, unsigned int, unsigned short, @@ -328,4 +347,12 @@ deliberate error cos this code looks bogus to me SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0); } - +%typemap(varout) SWIGTYPE (CLASS::*) +{ + void * p = emalloc(sizeof($1)); + memcpy(p, &$1, sizeof($1)); + zval * resource; + MAKE_STD_ZVAL(resource); + ZEND_REGISTER_RESOURCE(resource, p, le_member_ptr); + zend_hash_add(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void*)&resource, sizeof(zval *), NULL); +} diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 704b6c616..77985e3c5 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -354,6 +354,23 @@ SWIG_SetPointerZval($input, (void *)&$1_name, $1_descriptor, $owner); %} +%typemap(out) SWIGTYPE (CLASS::*) +{ + void * p = emalloc(sizeof($1)); + memcpy(p, &$1, sizeof($1)); + zval * resource; + MAKE_STD_ZVAL(resource); + ZEND_REGISTER_RESOURCE(resource, p, le_member_ptr); + + SWIG_SetPointerZval(return_value, (void *)&$1, $1_descriptor, $owner); +} + +%typemap(in) SWIGTYPE (CLASS::*) +{ + void * p = (void*)zend_fetch_resource($input TSRMLS_CC, -1, SWIG_MEMBER_PTR, NULL, 1, le_member_ptr); + memcpy(&$1, p, sizeof($1)); +} + %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { diff --git a/Lib/php/phpinit.swg b/Lib/php/phpinit.swg index b7a0fc9d4..5d8278ba4 100644 --- a/Lib/php/phpinit.swg +++ b/Lib/php/phpinit.swg @@ -8,5 +8,6 @@ %init %{ SWIG_php_minit { SWIG_InitializeModule(0); + le_member_ptr = zend_register_list_destructors_ex(member_ptr_dtor, NULL, SWIG_MEMBER_PTR, module_number); %} diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index f48748914..d3fe9d8c1 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -261,3 +261,12 @@ static void SWIG_Php_SetModule(swig_module_info *pointer) { TSRMLS_FETCH(); REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0); } + +#define SWIG_MEMBER_PTR ((char*)"CLASS::*") + +static void member_ptr_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC) { + efree(rsrc->ptr); +} + +static int le_member_ptr; + From 7ba280b4b8e5dbf16770f4ef801aa3e0262a510f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Dec 2009 13:58:44 +0000 Subject: [PATCH 262/352] Fix warnings for passing string constant for char * (the PHP API isn't const correct). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11769 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/php/phprun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index d3fe9d8c1..3aff867b4 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -36,7 +36,7 @@ extern "C" { #define SWIG_LONG_CONSTANT(N, V) zend_register_long_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) #define SWIG_DOUBLE_CONSTANT(N, V) zend_register_double_constant((char*)#N, sizeof(#N), V, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) -#define SWIG_STRING_CONSTANT(N, V) zend_register_stringl_constant((char*)#N, sizeof(#N), V, strlen(V), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) +#define SWIG_STRING_CONSTANT(N, V) zend_register_stringl_constant((char*)#N, sizeof(#N), (char*)(V), strlen(V), CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC) #define SWIG_CHAR_CONSTANT(N, V) do {\ static char swig_char = (V);\ zend_register_stringl_constant((char*)#N, sizeof(#N), &swig_char, 1, CONST_CS | CONST_PERSISTENT, module_number TSRMLS_CC);\ From 2c50482854b6e0ca27c28b567103ee045e916769 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 3 Dec 2009 14:12:42 +0000 Subject: [PATCH 263/352] Fix testcase to conform with actual expected behaviour. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11770 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/arrays_runme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/php/arrays_runme.php b/Examples/test-suite/php/arrays_runme.php index 7419504d1..1a4fe993f 100644 --- a/Examples/test-suite/php/arrays_runme.php +++ b/Examples/test-suite/php/arrays_runme.php @@ -12,7 +12,7 @@ check::classname(simplestruct,$ss); $as=new arraystruct(); $as->array_c="abc"; -check::equal($as->array_c,"ab",'$as->array_c=="ab"'); +check::equal($as->array_c,"a",'$as->array_c=="a"'); check::done(); ?> From 8461ba43ffb3b0bd7d6aa2a6cab68ce6b1cff5aa Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Dec 2009 03:54:24 +0000 Subject: [PATCH 264/352] Update lists of expected function, classes, and globals to match what we get with PHP5. There are no longer any warnings about these. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11771 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/php/arrays_global_runme.php | 2 +- Examples/test-suite/php/arrays_global_twodim_runme.php | 2 +- Examples/test-suite/php/arrays_runme.php | 3 +-- Examples/test-suite/php/arrays_scope_runme.php | 8 ++++---- Examples/test-suite/php/cpp_static_runme.php | 10 +++++----- Examples/test-suite/php/enum_scope_template_runme.php | 2 +- Examples/test-suite/php/ignore_parameter_runme.php | 10 +++++----- Examples/test-suite/php/li_carrays_runme.php | 6 +++--- 8 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Examples/test-suite/php/arrays_global_runme.php b/Examples/test-suite/php/arrays_global_runme.php index 7748786a1..12a7806c9 100644 --- a/Examples/test-suite/php/arrays_global_runme.php +++ b/Examples/test-suite/php/arrays_global_runme.php @@ -5,7 +5,7 @@ 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)); +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"); diff --git a/Examples/test-suite/php/arrays_global_twodim_runme.php b/Examples/test-suite/php/arrays_global_twodim_runme.php index 9f16a6cf6..40ecf1719 100644 --- a/Examples/test-suite/php/arrays_global_twodim_runme.php +++ b/Examples/test-suite/php/arrays_global_twodim_runme.php @@ -5,7 +5,7 @@ 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)); +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); diff --git a/Examples/test-suite/php/arrays_runme.php b/Examples/test-suite/php/arrays_runme.php index 1a4fe993f..23490e61e 100644 --- a/Examples/test-suite/php/arrays_runme.php +++ b/Examples/test-suite/php/arrays_runme.php @@ -4,8 +4,7 @@ require "arrays.php"; check::functions(array(fn_taking_arrays,newintpointer,setintfrompointer,getintfrompointer,array_pointer_func)); check::classes(array(arrays,SimpleStruct,ArrayStruct,CartPoseData_t)); -// No new vars -check::globals(array()); +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); diff --git a/Examples/test-suite/php/arrays_scope_runme.php b/Examples/test-suite/php/arrays_scope_runme.php index 6d3eba76d..c208b7518 100644 --- a/Examples/test-suite/php/arrays_scope_runme.php +++ b/Examples/test-suite/php/arrays_scope_runme.php @@ -3,12 +3,12 @@ require "tests.php"; require "arrays_scope.php"; -// No new functions +// New functions check::functions(array(new_bar,bar_blah)); -// No new classes +// New classes check::classes(array(arrays_scope,Bar)); -// now new vars -check::globals(array()); +// New vars +check::globals(array(bar_adata,bar_bdata,bar_cdata)); $bar=new bar(); diff --git a/Examples/test-suite/php/cpp_static_runme.php b/Examples/test-suite/php/cpp_static_runme.php index 9292a63cf..e1cc3e733 100644 --- a/Examples/test-suite/php/cpp_static_runme.php +++ b/Examples/test-suite/php/cpp_static_runme.php @@ -3,12 +3,12 @@ require "tests.php"; require "cpp_static.php"; -// No new functions -check::functions(array()); -// No new classes +// New functions +check::functions(array(staticfunctiontest_static_func,staticfunctiontest_static_func_2,staticfunctiontest_static_func_3)); +// New classes check::classes(array(StaticMemberTest,StaticFunctionTest)); -// now new vars -check::globals(array()); +// New vars +check::globals(array(staticmembertest_static_int)); check::done(); ?> diff --git a/Examples/test-suite/php/enum_scope_template_runme.php b/Examples/test-suite/php/enum_scope_template_runme.php index e152efca6..85ba467b7 100644 --- a/Examples/test-suite/php/enum_scope_template_runme.php +++ b/Examples/test-suite/php/enum_scope_template_runme.php @@ -3,7 +3,7 @@ require "tests.php"; require "enum_scope_template.php"; check::classes(array("enum_scope_template", "TreeInt")); -check::functions("chops"); +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"); diff --git a/Examples/test-suite/php/ignore_parameter_runme.php b/Examples/test-suite/php/ignore_parameter_runme.php index d455c39a1..1c8c76ad4 100644 --- a/Examples/test-suite/php/ignore_parameter_runme.php +++ b/Examples/test-suite/php/ignore_parameter_runme.php @@ -3,11 +3,11 @@ require "tests.php"; require "ignore_parameter.php"; -// No new functions -check::functions(array(jaguar,lotus,tvr,ferrari)); -// No new classes -check::classes(array(sportscars,minicooper,morrisminor,fordanglia,austinallegro)); -// now new vars +// 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"'); diff --git a/Examples/test-suite/php/li_carrays_runme.php b/Examples/test-suite/php/li_carrays_runme.php index b6d47e926..fbe5cc793 100644 --- a/Examples/test-suite/php/li_carrays_runme.php +++ b/Examples/test-suite/php/li_carrays_runme.php @@ -3,14 +3,14 @@ require "tests.php"; require "li_carrays.php"; // Check functions. -check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem)); +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)); -// No new global variables. -check::globals(array()); +// Check global variables. +check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray)); $d = new doubleArray(10); From 0633acd24f607a57d2dce65c9a5596df36ad9308 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Dec 2009 04:33:58 +0000 Subject: [PATCH 265/352] [PHP] "empty" is a reserved word in PHP, so rename empty() method on STL classes to "is_empty()" (previously this was automatically renamed to "c_empty()"). *** POTENTIAL INCOMPATIBILITY *** git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11772 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++++ Lib/php/std_map.i | 20 ++++++++++++-------- Lib/std/_std_deque.i | 25 +++++++++++++++++-------- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1c39df098..26c135d9a 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,12 @@ Version 1.3.41 (in progress) ============================ +2009-12-04: olly + [PHP] "empty" is a reserved word in PHP, so rename empty() method + on STL classes to "is_empty()" (previously this was automatically + renamed to "c_empty()"). + *** POTENTIAL INCOMPATIBILITY *** + 2009-12-03: olly [PHP] Add typemaps for long long and unsigned long long, and for pointer to method. diff --git a/Lib/php/std_map.i b/Lib/php/std_map.i index c6721806b..2c9e1fd9a 100644 --- a/Lib/php/std_map.i +++ b/Lib/php/std_map.i @@ -30,8 +30,6 @@ namespace std { map(const map &); unsigned int size() const; - %rename(is_empty) empty; - bool empty() const; void clear(); %extend { T& get(const K& key) throw (std::out_of_range) { @@ -55,6 +53,9 @@ namespace std { std::map::iterator i = self->find(key); return i != self->end(); } + bool is_empty() const { + return self->empty(); + } } }; @@ -70,8 +71,6 @@ namespace std { map(const map &); unsigned int size() const; - %rename(is_empty) empty; - bool empty() const; void clear(); %extend { T& get(K key) throw (std::out_of_range) { @@ -95,6 +94,9 @@ namespace std { std::map::iterator i = self->find(key); return i != self->end(); } + bool is_empty() const { + return self->empty(); + } } }; %enddef @@ -107,8 +109,6 @@ namespace std { map(const map &); unsigned int size() const; - %rename(is_empty) empty; - bool empty() const; void clear(); %extend { T get(const K& key) throw (std::out_of_range) { @@ -132,6 +132,9 @@ namespace std { std::map::iterator i = self->find(key); return i != self->end(); } + bool is_empty() const { + return self->empty(); + } } }; %enddef @@ -145,8 +148,6 @@ namespace std { map(const map &); unsigned int size() const; - %rename(is_empty) empty; - bool empty() const; void clear(); %extend { T get(K key) throw (std::out_of_range) { @@ -170,6 +171,9 @@ namespace std { std::map::iterator i = self->find(key); return i != self->end(); } + bool is_empty() const { + return self->empty(); + } } }; %enddef diff --git a/Lib/std/_std_deque.i b/Lib/std/_std_deque.i index 026f373d6..9b2908cec 100644 --- a/Lib/std/_std_deque.i +++ b/Lib/std/_std_deque.i @@ -27,7 +27,7 @@ }; */ -%define %std_deque_methods(T) +%define %std_deque_methods_noempty(T) typedef T &reference; typedef const T& const_reference; @@ -41,7 +41,6 @@ unsigned int size() const; unsigned int max_size() const; void resize(unsigned int n, T c = T()); - bool empty() const; const_reference front(); const_reference back(); void push_front(const T& x); @@ -69,7 +68,7 @@ throw std::out_of_range("deque index out of range"); } void delitem(int i) throw (std::out_of_range) { - int size = int(self->size()); + int size = int(self->size()); if (i<0) i+= size; if (i>=0 && ierase(self->begin()+i); @@ -77,7 +76,7 @@ throw std::out_of_range("deque index out of range"); } } - std::deque getslice(int i, int j) { + std::deque getslice(int i, int j) { int size = int(self->size()); if (i<0) i = size+i; if (j<0) j = size+j; @@ -112,15 +111,25 @@ self->erase(self->begin()+i,self->begin()+j); } }; - %enddef +#ifdef SWIGPHP +%define %std_deque_methods(T) + %extend { + bool is_empty() const { + return self->empty(); + } + }; +%enddef +#else +%define %std_deque_methods(T) + bool empty() const; +%enddef +#endif + namespace std { template class deque { public: %std_deque_methods(T); }; } - - - From bcda9644f1acd46cdabde5c1cb6ab8654a895a16 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Dec 2009 04:56:10 +0000 Subject: [PATCH 266/352] Remove two commented out lines of code. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11773 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index cbad1ee84..b427f9c64 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1929,9 +1929,7 @@ done: virtual int classHandler(Node *n) { constructors = 0; - //SwigType *t = Getattr(n, "classtype"); current_class = n; - // String *use_class_name=SwigType_manglestr(SwigType_ltype(t)); if (shadow) { char *rename = GetChar(n, "sym:name"); From 02eb6a81d1836cc7d39c171cb9074fbd98c01828 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Dec 2009 05:46:31 +0000 Subject: [PATCH 267/352] Fix handling of modulo operator (%) in constant expressions (SF#2818562). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11774 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Examples/test-suite/common.mk | 1 + Examples/test-suite/constant_expr.i | 11 +++++++++++ Source/CParse/parser.y | 6 +++--- 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 Examples/test-suite/constant_expr.i diff --git a/CHANGES.current b/CHANGES.current index 26c135d9a..cc1004148 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2009-12-04: olly + Fix handling of modulo operator (%) in constant expressions + (SF#2818562). + 2009-12-04: olly [PHP] "empty" is a reserved word in PHP, so rename empty() method on STL classes to "is_empty()" (previously this was automatically diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index bb72e4988..203ea3e72 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -441,6 +441,7 @@ C_TEST_CASES += \ arrays \ char_constant \ const_const \ + constant_expr \ empty \ enums \ extern_declaration \ diff --git a/Examples/test-suite/constant_expr.i b/Examples/test-suite/constant_expr.i new file mode 100644 index 000000000..47db2d026 --- /dev/null +++ b/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 % 6 +double d_array[12 % 6]; + +%} diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 46485593f..0da5c3122 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1647,7 +1647,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %token NATIVE INLINE %token TYPEMAP EXCEPT ECHO APPLY CLEAR SWIGTEMPLATE FRAGMENT %token WARN -%token LESSTHAN GREATERTHAN MODULO DELETE_KW +%token LESSTHAN GREATERTHAN DELETE_KW %token LESSTHANOREQUALTO GREATERTHANOREQUALTO EQUALTO NOTEQUALTO %token QUESTIONMARK %token TYPES PARMS @@ -1668,7 +1668,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { %left GREATERTHAN LESSTHAN GREATERTHANOREQUALTO LESSTHANOREQUALTO %left LSHIFT RSHIFT %left PLUS MINUS -%left STAR SLASH MODULUS +%left STAR SLASH MODULO %left UMINUS NOT LNOT %left DCOLON @@ -5745,7 +5745,7 @@ exprcompound : expr PLUS expr { $$.val = NewStringf("%s/%s",$1.val,$3.val); $$.type = promote($1.type,$3.type); } - | expr MODULUS expr { + | expr MODULO expr { $$.val = NewStringf("%s%%%s",$1.val,$3.val); $$.type = promote($1.type,$3.type); } From ab06b22bab63dbb1828934faa0c7fd9a444086c7 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 4 Dec 2009 08:52:12 +0000 Subject: [PATCH 268/352] [Ruby] Improve support for Ruby 1.9 under GCC. Addresses part of SF#2859614. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11775 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/ruby/rubyhead.swg | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index cc1004148..038485a13 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2009-12-04: olly + [Ruby] Improve support for Ruby 1.9 under GCC. Addresses part of + SF#2859614. + 2009-12-04: olly Fix handling of modulo operator (%) in constant expressions (SF#2818562). diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg index 4b425dfd8..9960087c6 100644 --- a/Lib/ruby/rubyhead.swg +++ b/Lib/ruby/rubyhead.swg @@ -1,5 +1,14 @@ #include +/* Ruby 1.9.1 has a "memoisation optimisation" when compiling with GCC which + * breaks using rb_intern as an lvalue, as SWIG does. We work around this + * issue for now by disabling this. + * https://sourceforge.net/tracker/?func=detail&aid=2859614&group_id=1645&atid=101645 + */ +#ifdef rb_intern +# undef rb_intern +#endif + /* Remove global macros defined in Ruby's win32.h */ #ifdef write # undef write From bfb09161f744bab4172b20c7f323909ed6b1abd3 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 10 Dec 2009 11:52:29 +0000 Subject: [PATCH 269/352] Eliminate "int error;" declaration from generated PHP director support code if it isn't used. No change in behaviour, and the compiler will just optimise away the unused variable, but it can cause an "unused variable" warning. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11776 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/php.cxx | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index b427f9c64..ca9d4e742 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2536,7 +2536,24 @@ done: } p = nextSibling(p); } - Append(w->code, "int error;\n"); + + /* exception handling */ + tm = Swig_typemap_lookup("director:except", n, "result", 0); + if (!tm) { + tm = Getattr(n, "feature:director:except"); + if (tm) + tm = Copy(tm); + } + if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { + if (Replaceall(tm, "$error", "error")) { + /* Only declare error if it is used by the typemap. */ + Append(w->code, "int error;\n"); + } + } else { + Delete(tm); + tm = NULL; + } + if (!idx) { Printf(w->code, "zval **args = NULL;\n", idx); } else { @@ -2555,18 +2572,10 @@ done: Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,\n"); Printf(w->code, " result, %d, args TSRMLS_CC);\n", idx); - /* exception handling */ - tm = Swig_typemap_lookup("director:except", n, "result", 0); - if (!tm) { - tm = Getattr(n, "feature:director:except"); - if (tm) - tm = Copy(tm); - } - if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) { - Replaceall(tm, "$error", "error"); + if (tm) { Printv(w->code, Str(tm), "\n", NIL); + Delete(tm); } - Delete(tm); /* marshal return value from PHP to C/C++ type */ From f65ad1caca6b7acbb7fde20e76f1f3242d536d31 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Thu, 10 Dec 2009 12:03:26 +0000 Subject: [PATCH 270/352] "make distclean" is supposed to return the source tree to a bootstrapped state so don't remove "configure" as that breaks "make distclean;./configure". Add new "maintainer-clean" target and remove configure in that instead. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11777 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CCache/Makefile.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CCache/Makefile.in b/CCache/Makefile.in index f885e72ae..ef20f48a0 100644 --- a/CCache/Makefile.in +++ b/CCache/Makefile.in @@ -63,8 +63,11 @@ test: test.sh check: test distclean: clean distclean-docs - /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status configure config.h.in ccache_swig_config.h + /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status config.h.in ccache_swig_config.h +maintainer-clean: distclean + /bin/rm -f configure + # FIXME: To fix this, test.sh needs to be able to take ccache from the # installed prefix, not from the source dir. installcheck: From 7bcc0699829bf4b7357f5e5930677ddace4dbd63 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 10 Dec 2009 22:34:02 +0000 Subject: [PATCH 271/352] Suppress incorrect 'unused value' bison warning git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11778 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 0da5c3122..b9db52104 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -3495,6 +3495,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { inclass = 1; } } cpp_members RBRACE cpp_opt_declarators { + (void) $6; if (nested_template == 0) { Node *p; SwigType *ty; @@ -3656,6 +3657,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { } cpp_members RBRACE declarator initializer c_decl_tail { String *unnamed; Node *n; + (void) $4; Classprefix = 0; $$ = class_decl[--class_level]; inclass = 0; From f3828ee02828c79df788a3758103295cbe79c8bc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 10 Dec 2009 22:58:55 +0000 Subject: [PATCH 272/352] nested class warning suppression git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11779 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/union_scope.i | 1 + 1 file changed, 1 insertion(+) diff --git a/Examples/test-suite/union_scope.i b/Examples/test-suite/union_scope.i index a41b30406..f66a0543a 100644 --- a/Examples/test-suite/union_scope.i +++ b/Examples/test-suite/union_scope.i @@ -3,6 +3,7 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) nRState; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) nRState_rstate; // Ruby, wrong class name %warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) nRState::rstate; +#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS %inline %{ class nRState { From 9354467b872e56b22f3156ceaa886f59795bf9fc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Dec 2009 21:11:45 +0000 Subject: [PATCH 273/352] remove Octave -api option and use new OCTAVE_API_VERSION_NUMBER instead git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11780 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/octave/octrun.swg | 34 +++++++++++++--------------------- Lib/octave/octruntime.swg | 6 +++--- Source/Modules/octave.cxx | 15 +-------------- 4 files changed, 21 insertions(+), 38 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 038485a13..1ff98e258 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2009-12-12: wsfulton + [Octave] Remove the -api option and use the new OCTAVE_API_VERSION_NUMBER + macro provided in the octave headers for determining the api version instead. + 2009-12-04: olly [Ruby] Improve support for Ruby 1.9 under GCC. Addresses part of SF#2859614. diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index a2bf52070..be2dc9653 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -1,24 +1,16 @@ -#if OCTAVE_API_VERSION_OPTION>0 -#define USE_OCTAVE_API_VERSION OCTAVE_API_VERSION_OPTION -#else - #include -#ifdef OCTAVE_API_VERSION_N -#define USE_OCTAVE_API_VERSION OCTAVE_API_VERSION_N +#ifndef OCTAVE_API_VERSION_NUMBER -#else // Interim hack to distinguish between Octave 3.2 and earlier versions. - -#define ComplexLU __ignore -#include -#undef ComplexLU -#ifdef octave_Complex_LU_h -#define USE_OCTAVE_API_VERSION 36 -#else -#define USE_OCTAVE_API_VERSION 37 -#endif - -#endif + // Hack to distinguish between Octave 3.2 and earlier versions before OCTAVE_API_VERSION_NUMBER existed + #define ComplexLU __ignore + #include + #undef ComplexLU + #ifdef octave_Complex_LU_h + # define OCTAVE_API_VERSION_NUMBER 36 + #else + # define OCTAVE_API_VERSION_NUMBER 37 + #endif #endif @@ -469,7 +461,7 @@ namespace Swig { install_builtin_function(it->second.first->method, it->first, it->second.first->doc?it->second.first->doc:std::string()); else if (it->second.second.is_defined()) { -#if USE_OCTAVE_API_VERSION<37 +#if OCTAVE_API_VERSION_NUMBER<37 link_to_global_variable(curr_sym_tab->lookup(it->first, true)); #else symbol_table::varref(it->first); @@ -477,7 +469,7 @@ namespace Swig { #endif set_global_value(it->first, it->second.second); -#if USE_OCTAVE_API_VERSION<37 +#if OCTAVE_API_VERSION_NUMBER<37 octave_swig_type *ost = Swig::swig_value_deref(it->second.second); if (ost) { const char* h = ost->help_text(); @@ -1389,7 +1381,7 @@ SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata) { SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *pointer) { octave_value ov = new octave_swig_packed(0, &pointer, sizeof(swig_module_info *)); const char *module_var = "__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION; -#if USE_OCTAVE_API_VERSION<37 +#if OCTAVE_API_VERSION_NUMBER<37 link_to_global_variable(curr_sym_tab->lookup(module_var, true)); #else symbol_table::varref(module_var); diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index 0ab7bd70b..e19b781c2 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -72,7 +72,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) { module_ns->install_global(); module_ns->decref(); -#if USE_OCTAVE_API_VERSION<37 +#if OCTAVE_API_VERSION_NUMBER<37 link_to_global_variable(curr_sym_tab->lookup(SWIG_name_d,true)); #else symbol_table::varref(SWIG_name_d); @@ -80,7 +80,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) { #endif set_global_value(SWIG_name_d,Swig::swig_value_ref(module_ns)); -#if USE_OCTAVE_API_VERSION>=37 +#if OCTAVE_API_VERSION_NUMBER>=37 mlock(); #endif @@ -89,7 +89,7 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) { // workaround bug in octave where installing global variable of custom type and then // exiting without explicitly clearing the variable causes octave to segfault. -#if USE_OCTAVE_API_VERSION>=37 +#if OCTAVE_API_VERSION_NUMBER>=37 struct oct_file_unload { ~oct_file_unload() { string_vector vars = symbol_table::global_variable_names(); diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index aeb72f77a..1804334d6 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -13,7 +13,7 @@ char cvsroot_octave_cxx[] = "$Id$"; static const char *usage = (char *) "\ Octave Options (available with -octave)\n\ - -api - Generate code that assumes Octave API N [default: 37]\n\ + [no additional options]\n\ \n"; @@ -36,8 +36,6 @@ private: int have_destructor; String *constructor_name; - int api_version; - Hash *docs; public: @@ -56,7 +54,6 @@ public: director_multiple_inheritance = 1; director_language = 1; docs = NewHash(); - api_version = 0; } virtual void main(int argc, char *argv[]) { @@ -64,15 +61,6 @@ public: if (argv[i]) { if (strcmp(argv[i], "-help") == 0) { fputs(usage, stderr); - } else if (strcmp(argv[i], "-api") == 0) { - if (argv[i + 1]) { - api_version = atoi(argv[i + 1]); - Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } } } } @@ -138,7 +126,6 @@ public: Printf(f_runtime, "#define SWIGOCTAVE\n"); Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module); Printf(f_runtime, "#define SWIG_name %s\n", module); - Printf(f_runtime, "#define OCTAVE_API_VERSION_OPTION %i\n", api_version); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); From f309dc92626364563af78de648a90412c6619fae Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 12 Dec 2009 22:27:22 +0000 Subject: [PATCH 274/352] gcc-4.4 warning fix for ruby git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11781 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/ruby/rubyrun.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index 24d861d5a..177e395d0 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -45,7 +45,7 @@ /* Error manipulation */ #define SWIG_ErrorType(code) SWIG_Ruby_ErrorType(code) -#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), msg) +#define SWIG_Error(code, msg) rb_raise(SWIG_Ruby_ErrorType(code), "%s", msg) #define SWIG_fail goto fail From 008ef5df5ab9885a06cb06c1a3a638e03045cc4a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 14 Dec 2009 20:44:51 +0000 Subject: [PATCH 275/352] Minor fix for warning suppression git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11782 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/union_scope.i | 1 - 1 file changed, 1 deletion(-) diff --git a/Examples/test-suite/union_scope.i b/Examples/test-suite/union_scope.i index f66a0543a..b7307cb29 100644 --- a/Examples/test-suite/union_scope.i +++ b/Examples/test-suite/union_scope.i @@ -2,7 +2,6 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME) nRState; // Ruby, wrong class name %warnfilter(SWIGWARN_RUBY_WRONG_NAME) nRState_rstate; // Ruby, wrong class name -%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) nRState::rstate; #pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS %inline %{ From fb4ad0b18de593f6b12546da3c98b7d16ceac287 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 Dec 2009 07:04:32 +0000 Subject: [PATCH 276/352] Add back in all the deque methods git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11783 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/std/_std_deque.i | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Lib/std/_std_deque.i b/Lib/std/_std_deque.i index 9b2908cec..3d68c385f 100644 --- a/Lib/std/_std_deque.i +++ b/Lib/std/_std_deque.i @@ -115,15 +115,17 @@ #ifdef SWIGPHP %define %std_deque_methods(T) - %extend { - bool is_empty() const { - return self->empty(); - } - }; + %extend { + bool is_empty() const { + return self->empty(); + } + }; + %std_deque_methods_noempty(T) %enddef #else %define %std_deque_methods(T) - bool empty() const; + bool empty() const; + %std_deque_methods_noempty(T) %enddef #endif From b86939aae57c47ac8233a5639858fd362c933044 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 15 Dec 2009 07:08:53 +0000 Subject: [PATCH 277/352] Remove redundant code which is no longer being used since the template specialization improvements were added git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11784 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/templ.c | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index 1f1620094..d78c12b1a 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -494,7 +494,7 @@ static EMatch does_parm_match(SwigType *type, SwigType *partial_parm_type, const static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) { Node *n = 0; - String *tname = 0, *rname = 0; + String *tname = 0; Node *templ; Symtab *primary_scope = 0; List *possiblepartials = 0; @@ -591,34 +591,6 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) { * only (1) is really supported for partial specializations */ - /* Generate reduced template name (stripped of extraneous pointers, etc.) */ - rname = NewStringf("%s<(", name); - p = parms; - while (p) { - String *t; - t = Getattr(p, "type"); - if (!t) - t = Getattr(p, "value"); - if (t) { - String *tyr = Swig_symbol_typedef_reduce(t, tscope); - String *ty = SwigType_strip_qualifiers(tyr); - String *tb = SwigType_base(ty); - String *td = SwigType_default(ty); - Replaceid(td, "enum SWIGTYPE", tb); - Replaceid(td, "SWIGTYPE", tb); - Append(rname, td); - Delete(tb); - Delete(td); - Delete(ty); - Delete(tyr); - } - p = nextSibling(p); - if (p) { - Append(rname, ","); - } - } - Append(rname, ")>"); - /* Rank each template parameter against the desired template parameters then build a matrix of best matches */ possiblepartials = NewList(); { @@ -819,7 +791,6 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) { } success: Delete(tname); - Delete(rname); Delete(possiblepartials); if ((template_debug) && (n)) { /* From 3a0e056d638625780612d6b81dadd84362e876c6 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 15 Dec 2009 14:29:03 +0000 Subject: [PATCH 278/352] Fix typo in literal string. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11785 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/php/cpointer/runme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/php/cpointer/runme.php b/Examples/php/cpointer/runme.php index f5ef08a3c..48f0ad631 100644 --- a/Examples/php/cpointer/runme.php +++ b/Examples/php/cpointer/runme.php @@ -22,7 +22,7 @@ # Now get the result $r = intp_value($c); - print " 38 + 42 = $r\n"; + print " 37 + 42 = $r\n"; # Clean up the pointers delete_intp($a); From d1eed0bc8ef9462e66418751284efa02e7c45235 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 15 Dec 2009 14:33:47 +0000 Subject: [PATCH 279/352] Don't use -Wno-long-double on OS X - it seems to no longer be supported by Apple's compilers, and was never supported by FSF GCC on any platform. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11786 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- configure.in | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/configure.in b/configure.in index 96c3d18b0..f457d73e3 100644 --- a/configure.in +++ b/configure.in @@ -316,11 +316,7 @@ esac # Optional CFLAGS used to silence compiler warnings on some platforms. AC_SUBST(PLATFLAGS) -case $host in - *-*-darwin*) PLATFLAGS="-Wno-long-double";; - *) PLATFLAGS="";; -esac - +PLATFLAGS= # Check for specific libraries. Used for SWIG examples AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV From 28983db50f045a12a4c192ce61d429112d60bda1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 17 Dec 2009 19:34:53 +0000 Subject: [PATCH 280/352] variable name corrections for consistency to use typemap method instead of op git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11787 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/typemap.c | 65 ++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 9fcbb38e0..b2c9ef3b2 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -223,7 +223,7 @@ void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms /* For a multi-argument typemap, the typemap code and information is really only stored in the last argument. However, to make this work, we perform a really neat trick using - the typemap operator name. + the typemap method name. For example, consider this typemap @@ -233,26 +233,26 @@ void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms To store it, we look at typemaps for the following: - operator type-name + typemap method type-name ---------------------------------------------- "in" int foo "in-int+foo:" int *bar "in-int+foo:-p.int+bar: char *blah[] - Notice how the operator expands to encode information about + Notice how the typemap method name expands to encode information about previous arguments. */ np = nextSibling(parms); if (np) { - /* Make an entirely new operator key */ - String *newop = NewStringf("%s-%s+%s:", tmap_method, type, pname); + /* Make an entirely new typemap method key */ + String *multi_tmap_method = NewStringf("%s-%s+%s:", tmap_method, type, pname); /* Now reregister on the remaining arguments */ - Swig_typemap_register(newop, np, code, locals, kwargs); + Swig_typemap_register(multi_tmap_method, np, code, locals, kwargs); - /* Setattr(tm2,newop,newop); */ - Delete(newop); + /* Setattr(tm2,multi_tmap_method,multi_tmap_method); */ + Delete(multi_tmap_method); } else { String *str = SwigType_str(type, pname); String *typemap = NewStringf("typemap(%s) %s", tmap_method, str); @@ -311,7 +311,7 @@ int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcparms, String *pname; SwigType *ptype; int ts = tm_scope; - String *tm_methods, *newop; + String *tm_methods, *multi_tmap_method; if (ParmList_len(parms) != ParmList_len(srcparms)) return -1; @@ -333,9 +333,9 @@ int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcparms, break; /* Got a match. Look for next typemap */ - newop = NewStringf("%s-%s+%s:", tm_methods, ptype, pname); + multi_tmap_method = NewStringf("%s-%s+%s:", tm_methods, ptype, pname); Delete(tm_methods); - tm_methods = newop; + tm_methods = multi_tmap_method; p = nextSibling(p); } Delete(tm_methods); @@ -363,11 +363,11 @@ void Swig_typemap_clear(const_String_or_char_ptr tmap_method, ParmList *parms) { SwigType *type; String *name; Parm *p; - String *newop; + String *multi_tmap_method; Hash *tm = 0; /* This might not work */ - newop = NewString(tmap_method); + multi_tmap_method = NewString(tmap_method); p = parms; while (p) { type = Getattr(p, "type"); @@ -377,17 +377,17 @@ void Swig_typemap_clear(const_String_or_char_ptr tmap_method, ParmList *parms) { return; p = nextSibling(p); if (p) - Printf(newop, "-%s+%s:", type, name); + Printf(multi_tmap_method, "-%s+%s:", type, name); } if (tm) { - tm = Getattr(tm, typemap_method_name(newop)); + tm = Getattr(tm, typemap_method_name(multi_tmap_method)); if (tm) { Delattr(tm, "code"); Delattr(tm, "locals"); Delattr(tm, "kwargs"); } } - Delete(newop); + Delete(multi_tmap_method); } /* ----------------------------------------------------------------------------- @@ -752,8 +752,9 @@ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList SwigType *type; SwigType *mtype = 0; String *name; - String *newop; - Hash *tm, *tm1; + String *multi_tmap_method; + Hash *tm; + Hash *tm1 = 0; if (!parms) { *nmatch = 0; @@ -769,8 +770,8 @@ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList Setattr(parms, "tmap:match", mtype); } Delete(mtype); - newop = NewStringf("%s-%s+%s:", tmap_method, type, name); - tm1 = typemap_search_multi(newop, nextSibling(parms), nmatch); + multi_tmap_method = NewStringf("%s-%s+%s:", tmap_method, type, name); + tm1 = typemap_search_multi(multi_tmap_method, nextSibling(parms), nmatch); if (tm1) tm = tm1; if (Getattr(tm, "code")) { @@ -778,7 +779,7 @@ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList } else { tm = 0; } - Delete(newop); + Delete(multi_tmap_method); } return tm; } @@ -1204,7 +1205,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No String *symname; String *cname = 0; String *clname = 0; - char *cop = Char(tmap_method); + char *cmethod = Char(tmap_method); int optimal_attribute = 0; int optimal_substitution = 0; int num_substitutions = 0; @@ -1269,7 +1270,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No Append(value, mangle); Delete(mangle); } - sprintf(temp, "%s:%s", cop, ckwname); + sprintf(temp, "%s:%s", cmethod, ckwname); Setattr(node, typemap_method_name(temp), value); if (Cmp(temp, "out:optimal") == 0) optimal_attribute = (Cmp(value, "0") != 0) ? 1 : 0; @@ -1361,20 +1362,20 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No Setattr(node, typemap_method_name(tmap_method), s); if (locals) { - sprintf(temp, "%s:locals", cop); + sprintf(temp, "%s:locals", cmethod); Setattr(node, typemap_method_name(temp), locals); Delete(locals); } if (Checkattr(tm, "type", "SWIGTYPE")) { - sprintf(temp, "%s:SWIGTYPE", cop); + sprintf(temp, "%s:SWIGTYPE", cmethod); Setattr(node, typemap_method_name(temp), "1"); } /* Look for warnings */ { String *w; - sprintf(temp, "%s:warning", cop); + sprintf(temp, "%s:warning", cmethod); w = Getattr(node, typemap_method_name(temp)); if (w) { Swig_warning(0, Getfile(node), Getline(node), "%s\n", w); @@ -1384,7 +1385,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No /* Look for code fragments */ { String *fragment; - sprintf(temp, "%s:fragment", cop); + sprintf(temp, "%s:fragment", cmethod); fragment = Getattr(node, typemap_method_name(temp)); if (fragment) { String *fname = Copy(fragment); @@ -1520,7 +1521,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p ParmList *locals; int argnum = 0; char temp[256]; - char *cop = Char(tmap_method); + char *cmethod = Char(tmap_method); String *kwmatch = 0; p = parms; @@ -1639,7 +1640,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p } if (Checkattr(tm, "type", "SWIGTYPE")) { - sprintf(temp, "%s:SWIGTYPE", cop); + sprintf(temp, "%s:SWIGTYPE", cmethod); Setattr(p, typemap_method_name(temp), "1"); } p = nextSibling(p); @@ -1662,13 +1663,13 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p Setattr(firstp, typemap_method_name(tmap_method), s); /* Code object */ if (locals) { - sprintf(temp, "%s:locals", cop); + sprintf(temp, "%s:locals", cmethod); Setattr(firstp, typemap_method_name(temp), locals); Delete(locals); } /* Attach a link to the next parameter. Needed for multimaps */ - sprintf(temp, "%s:next", cop); + sprintf(temp, "%s:next", cmethod); Setattr(firstp, typemap_method_name(temp), p); /* Attach kwargs */ @@ -1934,3 +1935,5 @@ void Swig_typemap_debug() { } Printf(stdout, "-----------------------------------------------------------------------------\n"); } + + From 9e2f8265b248eaad412fa31b0ebd7452e7a44be3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Dec 2009 11:23:20 +0000 Subject: [PATCH 281/352] Fix C comment stripping when the comment contains * git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11788 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/misc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 050e5357a..9b3e54fae 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -88,8 +88,8 @@ void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar) { /* ----------------------------------------------------------------------------- * Swig_strip_c_comments() * - * Return a new string with C comments stripped from the input string. Null is - * returned if there aren't any. + * Return a new string with C comments stripped from the input string. NULL is + * returned if there aren't any comments. * ----------------------------------------------------------------------------- */ String *Swig_strip_c_comments(const String *s) { @@ -107,9 +107,10 @@ String *Swig_strip_c_comments(const String *s) { comment_begin = c-1; } else if (comment_begin && !comment_end && *c == '*') { ++c; - if (*c == '/') + if (*c == '/') { comment_end = c; - break; + break; + } } ++c; } From 2e9624af945c1d520db9d97a69482e74ffc61f97 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 19 Dec 2009 11:47:05 +0000 Subject: [PATCH 282/352] Minor correction in a comment git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11789 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/templ.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index d78c12b1a..9cbd18d6b 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -457,11 +457,11 @@ static EMatch does_parm_match(SwigType *type, SwigType *partial_parm_type, const check for match to partial specialization type, for example, all of the following could match the type in the %template: template struct XX {}; template struct XX {}; // r.$1 - template struct XX {}; // r.q(const).$1 - template struct XX {}; // r.q(const).p.$1 + template struct XX {}; // r.q(const).$1 + template struct XX {}; // r.q(const).p.$1 %template(XXX) XX; // r.q(const).p.int - where type="r.q(const).p.int" will match either of tt="r.$1", tt="r.q(const)" tt="r.q(const).p" + where type="r.q(const).p.int" will match either of tt="r.", tt="r.q(const)" tt="r.q(const).p" */ Replaceid(tt, partial_parm_type_base, ""); /* remove the $1, $2 etc, eg tt="p.$1" => "p." */ len = Len(tt); From d1ff2c6a8bd1b259efb98185df611c71bad1df81 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 20 Dec 2009 00:24:34 +0000 Subject: [PATCH 283/352] Add -debug-tmsearch option for debugging the typemap pattern matching rules git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11790 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++ Doc/Manual/Typemaps.html | 111 ++++++++++++++++++++++++++++++++++++--- Source/Modules/main.cxx | 6 ++- Source/Swig/swig.h | 1 + Source/Swig/typemap.c | 83 +++++++++++++++++++++++++---- 5 files changed, 189 insertions(+), 16 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1ff98e258..570b0473f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2009-12-20: wsfulton + Add -debug-tmsearch option for debugging the typemap pattern matching rules. + Documented in Typemaps.html. + 2009-12-12: wsfulton [Octave] Remove the -api option and use the new OCTAVE_API_VERSION_NUMBER macro provided in the octave headers for determining the api version instead. diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 7a89a679a..3a8242866 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -31,10 +31,11 @@

    70. Pattern matching rules
    71. Code generation rules -
    72. Typemaps for multiple languages +
    73. Typemaps for multiple target languages
    74. Optimal code generation when returning by value
    75. Multi-argument typemaps
    76. The run-time type checker @@ -1090,7 +1091,7 @@ void F(int x[1000]); // int [ANY] rule (typemap 5)
    77. -

      10.3.2 Typedef reductions

      +

      10.3.2 Typedef reductions

      @@ -1432,6 +1433,104 @@ but all subsequent arguments must match exactly.

      +

      10.3.6 Debugging typemap pattern matching

      + + +

      +The -debug-tmsearch command line option is available for debugging typemap searches. +This can be very useful for watching the pattern matching process in action and for debugging which typemaps are used. +The option displays all the typemaps and types that are looked for until a successful pattern match is made. +As the display includes searches for each and every type needed for wrapping, the amount of information displayed can be large. +Normally you would manually search through the displayed information for the particular type that you are interested in. +

      + +

      +For example, consider some of the code used in the Typedef reductions section already covered: +

      + +
      +
      +typedef int Integer;
      +typedef Integer Row4[4];
      +void foo(Row4 rows[10]);
      +
      +
      + +

      +A sample of the debugging output is shown below for the "in" typemap: +

      + +
      +
      +swig -debug-tmsearch example.i
      +...
      +---- Searching for a suitable 'in' typemap for: Row4 rows[10]
      +  Looking for: Row4 rows[10]
      +  Looking for: Row4 [10]
      +  Looking for: Row4 [ANY]
      +  Looking for: Integer rows[10][4]
      +  Looking for: Integer [10][4]
      +  Looking for: Integer [ANY][ANY]
      +  Looking for: int rows[10][4]
      +  Looking for: int [10][4]
      +  Looking for: int [ANY][ANY]
      +  Looking for: SWIGTYPE rows[ANY][ANY]
      +  Looking for: SWIGTYPE [ANY][ANY]
      +  Looking for: SWIGTYPE rows[ANY][]
      +  Looking for: SWIGTYPE [ANY][]
      +  Looking for: SWIGTYPE *rows[ANY]
      +  Looking for: SWIGTYPE *[ANY]
      +  Looking for: SWIGTYPE rows[ANY]
      +  Looking for: SWIGTYPE [ANY]
      +  Looking for: SWIGTYPE rows[]
      +  Looking for: SWIGTYPE []
      +  Using: %typemap(in) SWIGTYPE []
      +...
      +
      +
      + +

      +showing that the best default match supplied by SWIG is the SWIGTYPE [] typemap. +As the example shows, the successful match displays just the typemap method name and type in this format: %typemap(method) type. +This information might meet your debugging needs, however, you might want to analyze further. +If you next invoke SWIG with the -E option to display the preprocessed output, and search for this particular typemap, +you'll find the full typemap contents (example shown below for Python): +

      + +
      +
      +%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0, int res = 0) {
      +  res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown |  0 );
      +  if (!SWIG_IsOK(res)) { 
      +    SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "$type""'"); 
      +  } 
      +  $1 = ($ltype)(argp);
      +}
      +
      +
      + +

      +The generated code for the foo wrapper will then contain the snippets of the typemap with the special variables expanded. +The rest of this chapter will need reading though to fully understand all of this, however, the relevant parts of the generated code for the above typemap can be seen below: +

      + +
      +
      +SWIGINTERN PyObject *_wrap_foo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
      +...
      +  void *argp1 = 0 ;
      +  int res1 = 0 ;
      +...
      +  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_a_4__int, 0 |  0 );
      +  if (!SWIG_IsOK(res1)) {
      +    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "foo" "', argument " "1"" of type '" "int [10][4]""'"); 
      +  } 
      +  arg1 = (int (*)[4])(argp1);
      +...
      +}
      +
      +
      +

      10.4 Code generation rules

      @@ -2705,12 +2804,12 @@ rather than blindly passing values to the underlying C/C++ program.

      Note: A more advanced constraint checking system is in development. Stay tuned.

      -

      10.7 Typemaps for multiple languages

      +

      10.7 Typemaps for multiple target languages

      The code within typemaps is usually language dependent, -however, many languages support the same typemaps. +however, many target languages support the same typemaps. In order to distinguish typemaps across different languages, the preprocessor should be used. For example, the "in" typemap for Perl and Ruby could be written as:

      @@ -3220,7 +3319,7 @@ language modules.
    78. The run-time type checker is used by many, but not all, of SWIG's supported target languages. The run-time type checker features -are not required and are thus not used for strongly typed languages such as Java and C#. +are not required and are thus not used for statically typed languages such as Java and C#. The scripting and scheme based languages rely on it and it forms a critical part of SWIG's operation for these languages.

      diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 4903416cd..9194d39a0 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -69,7 +69,8 @@ static const char *usage1 = (const char *) "\ -debug-template - Display information for debugging templates\n\ -debug-top - Display entire parse tree at stages 1-4, is a csv list of stages\n\ -debug-typedef - Display information about the types and typedefs in the interface\n\ - -debug-typemap - Display information for debugging typemaps\n\ + -debug-typemap - Display typemap debugging information\n\ + -debug-tmsearch - Display typemap search debugging information\n\ -directors - Turn on director mode for all the classes, mainly for testing\n\ -dirprot - Turn on wrapping of protected members for director classes (default)\n\ -D - Define a symbol (for conditional compilation)\n\ @@ -655,6 +656,9 @@ void SWIG_getoptions(int argc, char *argv[]) { } else if ((strcmp(argv[i], "-debug-typemap") == 0) || (strcmp(argv[i], "-debug_typemap") == 0) || (strcmp(argv[i], "-tm_debug") == 0)) { tm_debug = 1; Swig_mark_arg(i); + } else if (strcmp(argv[i], "-debug-tmsearch") == 0) { + Swig_typemap_search_debug_set(); + Swig_mark_arg(i); } else if (strcmp(argv[i], "-module") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 2c2d4aa3b..677176cf8 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -374,6 +374,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat); extern void Swig_typemap_clear_apply(ParmList *pattern); extern void Swig_typemap_debug(void); + extern void Swig_typemap_search_debug_set(void); extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f); extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index b2c9ef3b2..ffd9f5e19 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -17,6 +17,9 @@ char cvsroot_typemap_c[] = "$Id$"; #define SWIG_DEBUG #endif +static int typemap_search_debug = 0; +static int in_typemap_search_multi = 0; + static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f); /* ----------------------------------------------------------------------------- @@ -171,12 +174,12 @@ Hash *Swig_typemap_pop_scope() { #endif /* ----------------------------------------------------------------------------- - * Swig_typemap_register() + * typemap_register() * - * Add a new multi-argument typemap + * Internal implementation for Swig_typemap_register() * ----------------------------------------------------------------------------- */ -void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) { +static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs, const_String_or_char_ptr actual_tmap_method, ParmList *parmlist_start) { Hash *tm; Hash *tm1; Hash *tm2; @@ -249,13 +252,13 @@ void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms /* Make an entirely new typemap method key */ String *multi_tmap_method = NewStringf("%s-%s+%s:", tmap_method, type, pname); /* Now reregister on the remaining arguments */ - Swig_typemap_register(multi_tmap_method, np, code, locals, kwargs); + typemap_register(multi_tmap_method, np, code, locals, kwargs, actual_tmap_method, parmlist_start); /* Setattr(tm2,multi_tmap_method,multi_tmap_method); */ Delete(multi_tmap_method); } else { - String *str = SwigType_str(type, pname); - String *typemap = NewStringf("typemap(%s) %s", tmap_method, str); + String *parms_str = ParmList_str(parmlist_start); + String *typemap = NewStringf("typemap(%s) %s", actual_tmap_method, parms_str); ParmList *clocals = CopyParmList(locals); ParmList *ckwargs = CopyParmList(kwargs); @@ -271,11 +274,21 @@ void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms Delete(clocals); Delete(ckwargs); - Delete(str); + Delete(parms_str); Delete(typemap); } } +/* ----------------------------------------------------------------------------- + * Swig_typemap_register() + * + * Add a new, possibly multi-argument, typemap + * ----------------------------------------------------------------------------- */ + +void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) { + typemap_register(tmap_method, parms, code, locals, kwargs, tmap_method, parms); +} + /* ----------------------------------------------------------------------------- * typemap_get() * @@ -594,6 +607,13 @@ static SwigType *strip_arrays(SwigType *type) { return t; } +static void debug_search_result_display(Node *tm) { + if (tm) + Printf(stdout, " Using: %%%s\n", Getattr(tm, "typemap")); + else + Printf(stdout, " None found\n"); +} + /* ----------------------------------------------------------------------------- * typemap_search() * @@ -612,16 +632,23 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type const String *cname = 0; SwigType *unstripped = 0; String *tm_method = typemap_method_name(tmap_method); + int debug_display = (in_typemap_search_multi == 0) && typemap_search_debug; if ((name) && Len(name)) cname = name; ts = tm_scope; + if (debug_display) { + const String *empty_string = NewStringEmpty(); + Printf(stdout, "---- Searching for a suitable '%s' typemap for: %s\n", tmap_method, SwigType_str(type, cname ? cname : empty_string)); + } while (ts >= 0) { ctype = type; while (ctype) { /* Try to get an exact type-match */ tm = get_typemap(ts, ctype); + if (debug_display && cname) + Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cname)); if (tm && cname) { tm1 = Getattr(tm, cname); if (tm1) { @@ -632,6 +659,8 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type backup = result; } } + if (debug_display) + Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, 0)); if (tm) { result = Getattr(tm, tm_method); /* See if there is simply a type match */ if (result && Getattr(result, "code")) @@ -647,6 +676,8 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type noarrays = strip_arrays(ctype); } tma = get_typemap(ts, noarrays); + if (debug_display) + Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, 0)); if (tma && cname) { tm1 = Getattr(tma, cname); if (tm1) { @@ -694,11 +725,13 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type } } - /* Hmmm. Well, no match seems to be found at all. See if there is some kind of default mapping */ + /* Hmmm. Well, no match seems to be found at all. See if there is some kind of default (SWIGTYPE) mapping */ primitive = SwigType_default(type); while (primitive) { tm = get_typemap(ts, primitive); + if (debug_display && cname) + Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, cname)); if (tm && cname) { tm1 = Getattr(tm, cname); if (tm1) { @@ -707,6 +740,8 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type goto ret_result; } } + if (debug_display) + Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, 0)); if (tm) { /* See if there is simply a type match */ result = Getattr(tm, tm_method); if (result) @@ -771,16 +806,25 @@ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList } Delete(mtype); multi_tmap_method = NewStringf("%s-%s+%s:", tmap_method, type, name); + in_typemap_search_multi++; tm1 = typemap_search_multi(multi_tmap_method, nextSibling(parms), nmatch); + in_typemap_search_multi--; if (tm1) tm = tm1; if (Getattr(tm, "code")) { *(nmatch) = *nmatch + 1; + if (typemap_search_debug && tm1 && (in_typemap_search_multi == 0)) { + Printf(stdout, " Multi-argument typemap found...\n"); + } } else { tm = 0; } Delete(multi_tmap_method); } + + if (typemap_search_debug && (in_typemap_search_multi == 0)) + debug_search_result_display(tm); + return tm; } @@ -1236,16 +1280,25 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No if (qsn) { if (Len(qsn) && !Equal(qsn, pname)) { tm = typemap_search(tmap_method, type, qsn, &mtype); + /* TODO: move the search for qualified names into typemap_search to make it more efficient */ if (tm && (!Getattr(tm, "pname") || strstr(Char(Getattr(tm, "type")), "SWIGTYPE"))) { + if (typemap_search_debug) + Printf(stdout, " Found but not using\n"); tm = 0; + } else { + if (typemap_search_debug) + debug_search_result_display(tm); } } Delete(qsn); } } - if (!tm) + if (!tm) { #endif tm = typemap_search(tmap_method, type, pname, &mtype); + if (typemap_search_debug) + debug_search_result_display(tm); + } if (!tm) return sdef; @@ -1921,6 +1974,8 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper /* ----------------------------------------------------------------------------- * Swig_typemap_debug() + * + * Display all typemaps * ----------------------------------------------------------------------------- */ void Swig_typemap_debug() { @@ -1937,3 +1992,13 @@ void Swig_typemap_debug() { } +/* ----------------------------------------------------------------------------- + * Swig_typemap_search_debug_set() + * + * Turn on typemap searching debug display + * ----------------------------------------------------------------------------- */ + +void Swig_typemap_search_debug_set(void) { + typemap_search_debug = 1; +} + From f755bf73bfd1d626670caa27ded5876784b915c0 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 20 Dec 2009 01:19:48 +0000 Subject: [PATCH 284/352] Make docs on c++ source files more technically correct and fix some html errors git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11791 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index c17add4c5..5b6b6410e 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -330,11 +330,13 @@ currently supported:

        -
      • Non-conventional type declarations. +
      • +

        +Non-conventional type declarations. For example, SWIG does not support declarations such as the following (even though this is legal C): -

        +

         /* Non-conventional placement of storage specifier (extern) */
        @@ -348,7 +350,6 @@ void bar(Spam (Grok)(Doh));
         
         
        -

        In practice, few (if any) C programmers actually write code like @@ -357,27 +358,32 @@ if you're feeling particularly obfuscated, you can certainly break SWIG (althoug

      • -
      • Running SWIG on C++ source files (what would appear in a .C or .cxx file) -is not recommended. Even though SWIG can parse C++ class declarations, -it ignores declarations that are decoupled from their -original class definition (the declarations are parsed, but a lot of warning -messages may be generated). For example: +
      • +Running SWIG on C++ source files (the code in a .C, .cpp or .cxx file) is not recommended. +The usual approach is to feed SWIG header files for parsing C++ definitions and declarations. +The main reason is if SWIG parses a scoped definition or declaration (as is normal for C++ source files), +it is ignored, unless a declaration for the symbol was parsed earlier. +For example +

        -/* Not supported by SWIG */
        +/* bar not wrapped unless foo has been defined and 
        +   the declaration of bar within foo has already been parsed */
         int foo::bar(int) {
             ... whatever ...
         }
         
        -

      • -
      • Certain advanced features of C++ such as nested classes -are not yet fully supported. Please see the C++ section +
      • +

        +Certain advanced features of C++ such as nested classes +are not yet fully supported. Please see the C++ Nested classes section for more information. +

      From f83d09f2761c8fcf898a7af416c4ce0271d8b393 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 20 Dec 2009 01:20:50 +0000 Subject: [PATCH 285/352] Section number renumbering git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11792 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Contents.html | 8 +++----- Doc/Manual/Python.html | 3 --- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 108106035..0cda0b8f4 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -346,10 +346,11 @@

    79. Pattern matching rules
    80. Code generation rules -
    81. Typemaps for multiple languages +
    82. Typemaps for multiple target languages
    83. Optimal code generation when returning by value
    84. Multi-argument typemaps
    85. The run-time type checker @@ -1280,9 +1281,6 @@
    86. Simple pointers
    87. Unbounded C Arrays
    88. String handling -
    89. Arrays -
    90. String arrays -
    91. STL wrappers
    92. Typemaps
    93. Typemaps
        From ac224e857007a76fb63ab026fb82bb2d3cc0e606 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 21 Dec 2009 01:08:53 +0000 Subject: [PATCH 286/352] -debug-tmsearch improvements and fixes. Also slightly more efficient typemap searches when using fully qualified names. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11793 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Typemaps.html | 3 ++ Source/Swig/typemap.c | 113 ++++++++++++++++++++++++--------------- 2 files changed, 74 insertions(+), 42 deletions(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 3a8242866..bd9d6dbeb 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -1467,12 +1467,15 @@ swig -debug-tmsearch example.i ---- Searching for a suitable 'in' typemap for: Row4 rows[10] Looking for: Row4 rows[10] Looking for: Row4 [10] + Looking for: Row4 rows[ANY] Looking for: Row4 [ANY] Looking for: Integer rows[10][4] Looking for: Integer [10][4] + Looking for: Integer rows[ANY][ANY] Looking for: Integer [ANY][ANY] Looking for: int rows[10][4] Looking for: int [10][4] + Looking for: int rows[ANY][ANY] Looking for: int [ANY][ANY] Looking for: SWIGTYPE rows[ANY][ANY] Looking for: SWIGTYPE [ANY][ANY] diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index ffd9f5e19..1d69d5c9c 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -617,11 +617,12 @@ static void debug_search_result_display(Node *tm) { /* ----------------------------------------------------------------------------- * typemap_search() * - * Search for a typemap match. Tries to find the most specific typemap - * that includes a 'code' attribute. + * Search for a typemap match. This is where the typemap pattern matching rules + * are implemented... tries to find the most specific typemap that includes a + * 'code' attribute. * ----------------------------------------------------------------------------- */ -static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type, const_String_or_char_ptr name, SwigType **matchtype) { +static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type, const_String_or_char_ptr name, const_String_or_char_ptr qualifiedname, SwigType **matchtype) { Hash *result = 0, *tm, *tm1, *tma; Hash *backup = 0; SwigType *noarrays = 0; @@ -630,29 +631,46 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type int ts; int isarray; const String *cname = 0; + const String *cqualifiedname = 0; SwigType *unstripped = 0; String *tm_method = typemap_method_name(tmap_method); int debug_display = (in_typemap_search_multi == 0) && typemap_search_debug; if ((name) && Len(name)) cname = name; + if ((qualifiedname) && Len(qualifiedname)) + cqualifiedname = qualifiedname; ts = tm_scope; if (debug_display) { const String *empty_string = NewStringEmpty(); - Printf(stdout, "---- Searching for a suitable '%s' typemap for: %s\n", tmap_method, SwigType_str(type, cname ? cname : empty_string)); + String *typestr = SwigType_str(type, cqualifiedname ? cqualifiedname : (cname ? cname : empty_string)); + Printf(stdout, "---- Searching for a suitable '%s' typemap for: %s\n", tmap_method, typestr); + Delete(typestr); } while (ts >= 0) { ctype = type; while (ctype) { /* Try to get an exact type-match */ tm = get_typemap(ts, ctype); + if (debug_display && cqualifiedname) + Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cqualifiedname)); + if (tm && cqualifiedname) { + tm1 = Getattr(tm, cqualifiedname); + if (tm1) { + result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */ + if (result && Getattr(result, "code")) + goto ret_result; + if (result) + backup = result; + } + } if (debug_display && cname) Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cname)); if (tm && cname) { tm1 = Getattr(tm, cname); if (tm1) { - result = Getattr(tm1, tm_method); /* See if there is a type-name match */ + result = Getattr(tm1, tm_method); /* See if there is a type - name match */ if (result && Getattr(result, "code")) goto ret_result; if (result) @@ -676,20 +694,34 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type noarrays = strip_arrays(ctype); } tma = get_typemap(ts, noarrays); - if (debug_display) - Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, 0)); - if (tma && cname) { - tm1 = Getattr(tma, cname); + if (debug_display && cqualifiedname) + Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, cqualifiedname)); + if (tma && cqualifiedname) { + tm1 = Getattr(tma, cqualifiedname); if (tm1) { - result = Getattr(tm1, tm_method); /* type-name match */ + result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */ if (result && Getattr(result, "code")) goto ret_result; if (result) backup = result; } } + if (debug_display && cname) + Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, cname)); + if (tma && cname) { + tm1 = Getattr(tma, cname); + if (tm1) { + result = Getattr(tm1, tm_method); /* See if there is a type - name match */ + if (result && Getattr(result, "code")) + goto ret_result; + if (result) + backup = result; + } + } + if (debug_display) + Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, 0)); if (tma) { - result = Getattr(tma, tm_method); /* type match */ + result = Getattr(tma, tm_method); /* See if there is a type match */ if (result && Getattr(result, "code")) goto ret_result; if (result) @@ -730,20 +762,30 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type primitive = SwigType_default(type); while (primitive) { tm = get_typemap(ts, primitive); + if (debug_display && cqualifiedname) + Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, cqualifiedname)); + if (tm && cqualifiedname) { + tm1 = Getattr(tm, cqualifiedname); + if (tm1) { + result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */ + if (result) + goto ret_result; + } + } if (debug_display && cname) Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, cname)); if (tm && cname) { tm1 = Getattr(tm, cname); if (tm1) { - result = Getattr(tm1, tm_method); /* See if there is a type-name match */ + result = Getattr(tm1, tm_method); /* See if there is a type - name match */ if (result) goto ret_result; } } if (debug_display) Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, 0)); - if (tm) { /* See if there is simply a type match */ - result = Getattr(tm, tm_method); + if (tm) { + result = Getattr(tm, tm_method); /* See if there is simply a type match */ if (result) goto ret_result; } @@ -799,7 +841,7 @@ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList name = Getattr(parms, "name"); /* Try to find a match on the first type */ - tm = typemap_search(tmap_method, type, name, &mtype); + tm = typemap_search(tmap_method, type, name, 0, &mtype); if (tm) { if (mtype && SwigType_isarray(mtype)) { Setattr(parms, "tmap:match", mtype); @@ -1240,6 +1282,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No SwigType *type; SwigType *mtype = 0; String *pname; + String *qpname = 0; Hash *tm = 0; String *s = 0; String *sdef = 0; @@ -1254,8 +1297,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No int optimal_substitution = 0; int num_substitutions = 0; - /* special case, we need to check for 'ref' call - and set the default code 'sdef' */ + /* special case, we need to check for 'ref' call and set the default code 'sdef' */ if (node && Cmp(tmap_method, "newfree") == 0) { sdef = Swig_ref_call(node, lname); } @@ -1266,39 +1308,26 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No pname = Getattr(node, "name"); -#if 1 if (pname && node && checkAttribute(node, "kind", "function")) { /* - For functions, look qualified names first, such as - + For functions, add on a qualified name search, for example struct Foo { - int *foo(int bar) -> Foo::foo + int *foo(int bar) -> Foo::foo }; */ Symtab *st = Getattr(node, "sym:symtab"); String *qsn = st ? Swig_symbol_string_qualify(pname, st) : 0; - if (qsn) { - if (Len(qsn) && !Equal(qsn, pname)) { - tm = typemap_search(tmap_method, type, qsn, &mtype); - /* TODO: move the search for qualified names into typemap_search to make it more efficient */ - if (tm && (!Getattr(tm, "pname") || strstr(Char(Getattr(tm, "type")), "SWIGTYPE"))) { - if (typemap_search_debug) - Printf(stdout, " Found but not using\n"); - tm = 0; - } else { - if (typemap_search_debug) - debug_search_result_display(tm); - } - } - Delete(qsn); - } - } - if (!tm) { -#endif - tm = typemap_search(tmap_method, type, pname, &mtype); - if (typemap_search_debug) - debug_search_result_display(tm); + if (qsn && Len(qsn) && !Equal(qsn, pname)) + qpname = qsn; } + + tm = typemap_search(tmap_method, type, pname, qpname, &mtype); + if (typemap_search_debug) + debug_search_result_display(tm); + + Delete(qpname); + qpname = 0; + if (!tm) return sdef; From 97f959ddf03ecc915499ca4c952127fc489e857c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 22 Dec 2009 19:21:55 +0000 Subject: [PATCH 287/352] Slight improvement to -debug-tmsearch and multi-argument typemaps git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11794 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Typemaps.html | 18 +++++++++++++++++- Source/Swig/typemap.c | 11 ++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index bd9d6dbeb..43ab01248 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -1403,7 +1403,7 @@ Expect to see them being used more and more within the various libraries in late

        -

        10.3.5 Multi-arguments typemaps

        +

        10.3.5 Multi-arguments typemaps

        @@ -1534,6 +1534,22 @@ SWIGINTERN PyObject *_wrap_foo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {

    94. +

      +Searches for multi-argument typemaps are not mentioned unless a matching multi-argument typemap does actually exist. +For example, the output for the code in the previous section is as follows: +

      + +
      +
      +...
      +---- Searching for a suitable 'in' typemap for: char *buffer
      +  Looking for: char *buffer
      +  Multi-argument typemap found...
      +  Using: %typemap(in) (char *buffer,int len)
      +...
      +
      +
      +

      10.4 Code generation rules

      diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 1d69d5c9c..d38f00db9 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -257,10 +257,14 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par /* Setattr(tm2,multi_tmap_method,multi_tmap_method); */ Delete(multi_tmap_method); } else { - String *parms_str = ParmList_str(parmlist_start); - String *typemap = NewStringf("typemap(%s) %s", actual_tmap_method, parms_str); ParmList *clocals = CopyParmList(locals); ParmList *ckwargs = CopyParmList(kwargs); + String *parms_str = ParmList_str(parmlist_start); + String *typemap; + if (ParmList_len(parmlist_start) > 1) + typemap = NewStringf("typemap(%s) (%s)", actual_tmap_method, parms_str); + else + typemap = NewStringf("typemap(%s) %s", actual_tmap_method, parms_str); Setattr(tm2, "code", code); Setattr(tm2, "type", type); @@ -643,10 +647,11 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type ts = tm_scope; if (debug_display) { - const String *empty_string = NewStringEmpty(); + String *empty_string = NewStringEmpty(); String *typestr = SwigType_str(type, cqualifiedname ? cqualifiedname : (cname ? cname : empty_string)); Printf(stdout, "---- Searching for a suitable '%s' typemap for: %s\n", tmap_method, typestr); Delete(typestr); + Delete(empty_string); } while (ts >= 0) { ctype = type; From eefaef3bdbd1bf6dda0d45dcce17540849857a64 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 22 Dec 2009 23:08:28 +0000 Subject: [PATCH 288/352] Add link for const sections git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11795 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIG.html | 6 ++++++ Doc/Manual/SWIGPlus.html | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 5b6b6410e..02d0ca3a4 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -797,6 +797,12 @@ In this case, the pointer e can change---it's only the value being pointed to that is read-only.

      +

      +Please note that for const parameters or return types used in a function, SWIG pretty much ignores +the fact that these are const, see the section on const-correctness +for more information. +

      +

      Compatibility Note: One reason for changing SWIG to handle const declarations as read-only variables is that there are diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 3836c86a7..8e051a0ec 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -56,7 +56,7 @@

    95. Smart pointers and operator->()
    96. Using declarations and inheritance
    97. Nested classes -
    98. A brief rant about const-correctness +
    99. A brief rant about const-correctness
    100. Where to go for more information @@ -4835,7 +4835,7 @@ Nested class warnings could also not be suppressed using %warnfilter.

      -

      6.27 A brief rant about const-correctness

      +

      6.27 A brief rant about const-correctness

      From bd84f7f794f94348a6b13cb96fa9cd81e761e245 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 23 Dec 2009 00:02:52 +0000 Subject: [PATCH 289/352] add link to %%newobject section git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11796 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Library.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index eaebbede5..833a38393 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -890,7 +890,10 @@ char *foo();

      -This will release the result. +This will release the result if the appropriate target language support is available. +SWIG provides the appropriate "newfree" typemap for char * so that the memory is released, +however, you may need to provide your own "newfree" typemap for other types. +See Object ownership and %newobject for more details.

      8.3.4 cstring.i

      From 6dad327ed37aa43e781a1dd802cf38fac91de84c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 23 Dec 2009 01:05:17 +0000 Subject: [PATCH 290/352] Fix for %%javaexception and directors so that all the appropriate throws clauses are generated git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11797 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ .../test-suite/java/java_director_runme.java | 17 +++++++++++++++++ Examples/test-suite/java_director.i | 8 ++++++++ Source/Modules/java.cxx | 3 +++ 4 files changed, 32 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 570b0473f..92b882c4c 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2009-12-23: wsfulton + Fix for %javaexception and directors so that all the appropriate throws clauses + are generated. Problem reported by Peter Greenwood. + 2009-12-20: wsfulton Add -debug-tmsearch option for debugging the typemap pattern matching rules. Documented in Typemaps.html. diff --git a/Examples/test-suite/java/java_director_runme.java b/Examples/test-suite/java/java_director_runme.java index dffba0ea5..86c92d49a 100644 --- a/Examples/test-suite/java/java_director_runme.java +++ b/Examples/test-suite/java/java_director_runme.java @@ -34,6 +34,12 @@ public class java_director_runme { 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(); @@ -73,3 +79,14 @@ class java_director_MyQuux extends Quux { 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/Examples/test-suite/java_director.i b/Examples/test-suite/java_director.i index 04d55e196..03d733d6a 100644 --- a/Examples/test-suite/java_director.i +++ b/Examples/test-suite/java_director.i @@ -122,3 +122,11 @@ struct JObjectTest { %} +%javaexception("Exception") etest "$action" +%inline %{ +struct JavaExceptionTest { + virtual ~JavaExceptionTest() {} + virtual void etest() {} +}; +%} + diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 7fccab5e1..bef41b0d2 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -3724,6 +3724,9 @@ public: String *upcall = NewStringf("self.%s(%s)", symname, imcall_args); + // Handle exception classes specified in the "except" feature's "throws" attribute + addThrows(n, "feature:except", n); + if (!is_void) { Parm *tp = NewParmFromNode(returntype, empty_str, n); From 1e8fa8fee022de3151209d0719aa30aa0fdb4e65 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 Dec 2009 15:50:03 +0000 Subject: [PATCH 291/352] remove warn.c - it isn't used git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11798 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/swig.h | 5 ----- Source/Swig/warn.c | 34 ---------------------------------- 2 files changed, 39 deletions(-) delete mode 100644 Source/Swig/warn.c diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 677176cf8..5108c7d33 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -307,13 +307,8 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern String *Swig_string_title(String *s); extern void Swig_init(void); - extern void Swig_warn(const char *filename, int line, const char *msg); - extern int Swig_value_wrapper_mode(int mode); - -#define WARNING(msg) Swig_warn(__FILE__,__LINE__,msg) - typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat; extern void Swig_warning(int num, const_String_or_char_ptr filename, int line, const char *fmt, ...); diff --git a/Source/Swig/warn.c b/Source/Swig/warn.c deleted file mode 100644 index a8dadc70b..000000000 --- a/Source/Swig/warn.c +++ /dev/null @@ -1,34 +0,0 @@ -/* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * - * warn.c - * - * SWIG warning framework. This was added to warn developers about - * deprecated APIs and other features. - * ----------------------------------------------------------------------------- */ - -char cvsroot_warn_c[] = "$Id$"; - -#include "swig.h" - -static Hash *warnings = 0; - -/* ----------------------------------------------------------------------------- - * Swig_warn() - * - * Issue a warning - * ----------------------------------------------------------------------------- */ - -void Swig_warn(const char *filename, int line, const char *msg) { - String *key; - if (!warnings) { - warnings = NewHash(); - } - key = NewStringf("%s:%d", filename, line); - if (!Getattr(warnings, key)) { - Printf(stderr, "swig-dev warning:%s:%d:%s\n", filename, line, msg); - Setattr(warnings, key, key); - } - Delete(key); -} From 9bc7f3c676c5597504a38e1a1824f4c00ed6463a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 Dec 2009 15:53:01 +0000 Subject: [PATCH 292/352] remove warn.c - it isn't used git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11799 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Makefile.am | 1 - 1 file changed, 1 deletion(-) diff --git a/Source/Makefile.am b/Source/Makefile.am index aadf50d28..bc3222b25 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -86,7 +86,6 @@ eswig_SOURCES = CParse/cscanner.c \ Swig/typeobj.c \ Swig/typemap.c \ Swig/typesys.c \ - Swig/warn.c \ Swig/wrapfunc.c bin_PROGRAMS = eswig From 6b2fe71e0ed9f6b7cc7d33245ce64d792a278620 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 Dec 2009 16:51:45 +0000 Subject: [PATCH 293/352] Add Swig_diagnostic() for displaying file and line number messages to stdout git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11800 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/error.c | 34 ++++++++++++++++++++++++++++++++-- Source/Swig/swig.h | 1 + 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Source/Swig/error.c b/Source/Swig/error.c index 156fe06a7..0f4728954 100644 --- a/Source/Swig/error.c +++ b/Source/Swig/error.c @@ -49,13 +49,15 @@ static char wrn_wnum_fmt[64]; static char wrn_nnum_fmt[64]; static char err_line_fmt[64]; static char err_eof_fmt[64]; +static char diag_line_fmt[64]; +static char diag_eof_fmt[64]; static String *format_filename(const_String_or_char_ptr filename); /* ----------------------------------------------------------------------------- * Swig_warning() * - * Issue a warning message + * Issue a warning message on stderr. * ----------------------------------------------------------------------------- */ void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const char *fmt, ...) { @@ -118,7 +120,7 @@ void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const c /* ----------------------------------------------------------------------------- * Swig_error() * - * Issue an error message + * Issue an error message on stderr. * ----------------------------------------------------------------------------- */ void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...) { @@ -258,6 +260,8 @@ void Swig_error_msg_format(ErrorMessageFormat format) { sprintf(wrn_nnum_fmt, "%s: %s: ", fmt_line, warning); sprintf(err_line_fmt, "%s: %s: ", fmt_line, error); sprintf(err_eof_fmt, "%s: %s: ", fmt_eof, error); + sprintf(diag_line_fmt, "%s: ", fmt_line); + sprintf(diag_eof_fmt, "%s: ", fmt_eof); msg_format = format; init_fmt = 1; @@ -275,3 +279,29 @@ static String *format_filename(const_String_or_char_ptr filename) { #endif return formatted_filename; } + +/* ----------------------------------------------------------------------------- + * Swig_diagnostic() + * + * Issue a diagnostic message on stdout. + * ----------------------------------------------------------------------------- */ + +void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...) { + va_list ap; + String *formatted_filename = NULL; + + if (!init_fmt) + Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT); + + va_start(ap, fmt); + formatted_filename = format_filename(filename); + if (line > 0) { + Printf(stdout, diag_line_fmt, formatted_filename, line); + } else { + Printf(stdout, diag_eof_fmt, formatted_filename); + } + vPrintf(stdout, fmt, ap); + va_end(ap); + Delete(formatted_filename); +} + diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 5108c7d33..8c4d50000 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -319,6 +319,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Swig_warnall(void); extern int Swig_warn_count(void); extern void Swig_error_msg_format(ErrorMessageFormat format); + extern void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...); /* --- C Wrappers --- */ extern String *Swig_cparm_name(Parm *p, int i); From 8b7c0afcfc7ba5fce62b11bb17932f3310dceef9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 24 Dec 2009 17:00:35 +0000 Subject: [PATCH 294/352] Display filename and line number in output when using -debug-tmsearch git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11801 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Typemaps.html | 4 ++-- Source/Swig/typemap.c | 51 +++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 43ab01248..89cae62a3 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -1464,7 +1464,7 @@ A sample of the debugging output is shown below for the "in" typemap:
       swig -debug-tmsearch example.i
       ...
      ----- Searching for a suitable 'in' typemap for: Row4 rows[10]
      +example.h:26: Searching for a suitable 'in' typemap for: Row4 rows[10]
         Looking for: Row4 rows[10]
         Looking for: Row4 [10]
         Looking for: Row4 rows[ANY]
      @@ -1542,7 +1542,7 @@ For example, the output for the code in the 
       
       ...
      ----- Searching for a suitable 'in' typemap for: char *buffer
      +example.h:39: Searching for a suitable 'in' typemap for: char *buffer
         Looking for: char *buffer
         Multi-argument typemap found...
         Using: %typemap(in) (char *buffer,int len)
      diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c
      index d38f00db9..3bb4e6909 100644
      --- a/Source/Swig/typemap.c
      +++ b/Source/Swig/typemap.c
      @@ -626,7 +626,7 @@ static void debug_search_result_display(Node *tm) {
        * 'code' attribute.
        * ----------------------------------------------------------------------------- */
       
      -static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type, const_String_or_char_ptr name, const_String_or_char_ptr qualifiedname, SwigType **matchtype) {
      +static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type, const_String_or_char_ptr name, const_String_or_char_ptr qualifiedname, SwigType **matchtype, Node *node) {
         Hash *result = 0, *tm, *tm1, *tma;
         Hash *backup = 0;
         SwigType *noarrays = 0;
      @@ -649,7 +649,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
         if (debug_display) {
           String *empty_string = NewStringEmpty();
           String *typestr = SwigType_str(type, cqualifiedname ? cqualifiedname : (cname ? cname : empty_string));
      -    Printf(stdout, "---- Searching for a suitable '%s' typemap for: %s\n", tmap_method, typestr);
      +    Swig_diagnostic(Getfile(node), Getline(node), "Searching for a suitable '%s' typemap for: %s\n", tmap_method, typestr);
           Delete(typestr);
           Delete(empty_string);
         }
      @@ -846,7 +846,7 @@ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList
         name = Getattr(parms, "name");
       
         /* Try to find a match on the first type */
      -  tm = typemap_search(tmap_method, type, name, 0, &mtype);
      +  tm = typemap_search(tmap_method, type, name, 0, &mtype, parms);
         if (tm) {
           if (mtype && SwigType_isarray(mtype)) {
             Setattr(parms, "tmap:match", mtype);
      @@ -1259,6 +1259,22 @@ static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) {
         }
       }
       
      +/* -----------------------------------------------------------------------------
      + * typemap_warn()
      + *
      + * If any warning message is attached to this parameter's "tmap::warning"
      + * attribute, print that warning message.
      + * ----------------------------------------------------------------------------- */
      +
      +static void typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) {
      +  String *temp = NewStringf("%s:warning", tmap_method);
      +  String *w = Getattr(p, typemap_method_name(temp));
      +  Delete(temp);
      +  if (w) {
      +    Swig_warning(0, Getfile(p), Getline(p), "%s\n", w);
      +  }
      +}
      +
       /* -----------------------------------------------------------------------------
        * Swig_typemap_lookup()
        *
      @@ -1326,7 +1342,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
             qpname = qsn;
         }
       
      -  tm = typemap_search(tmap_method, type, pname, qpname, &mtype);
      +  tm = typemap_search(tmap_method, type, pname, qpname, &mtype, node);
         if (typemap_search_debug)
           debug_search_result_display(tm);
       
      @@ -1459,15 +1475,8 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
           Setattr(node, typemap_method_name(temp), "1");
         }
       
      -  /* Look for warnings */
      -  {
      -    String *w;
      -    sprintf(temp, "%s:warning", cmethod);
      -    w = Getattr(node, typemap_method_name(temp));
      -    if (w) {
      -      Swig_warning(0, Getfile(node), Getline(node), "%s\n", w);
      -    }
      -  }
      +  /* Print warnings, if any */
      +  typemap_warn(cmethod, node);
       
         /* Look for code fragments */
         {
      @@ -1542,22 +1551,6 @@ static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method
         Delete(temp);
       }
       
      -/* -----------------------------------------------------------------------------
      - * typemap_warn()
      - *
      - * If any warning message is attached to this parameter's "tmap::warning"
      - * attribute, print that warning message.
      - * ----------------------------------------------------------------------------- */
      -
      -static void typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) {
      -  String *temp = NewStringf("%s:warning", tmap_method);
      -  String *w = Getattr(p, typemap_method_name(temp));
      -  Delete(temp);
      -  if (w) {
      -    Swig_warning(0, Getfile(p), Getline(p), "%s\n", w);
      -  }
      -}
      -
       static void typemap_emit_code_fragments(const_String_or_char_ptr tmap_method, Parm *p) {
         String *temp = NewStringf("%s:fragment", tmap_method);
         String *f = Getattr(p, typemap_method_name(temp));
      
      From 83bd8202859d9d703cc9ace6c3827c5f12047bd6 Mon Sep 17 00:00:00 2001
      From: William S Fulton 
      Date: Mon, 4 Jan 2010 19:33:52 +0000
      Subject: [PATCH 295/352] Add typemaps used debugging option (-debug-tmused).
       Fix missing file/line numbers for typemap warnings and in the output from the
       -debug-tmsearch/-debug-tmused options
      
      git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11802 626c5289-ae23-0410-ae9c-e8d60b6d4f22
      ---
       CHANGES.current             | 10 ++++++++++
       Doc/Manual/Typemaps.html    | 26 ++++++++++++++++++++++---
       Source/CParse/cparse.h      |  2 +-
       Source/CParse/parser.y      | 22 +++++++++++----------
       Source/CParse/templ.c       |  2 +-
       Source/Modules/allocate.cxx |  2 +-
       Source/Modules/cffi.cxx     | 12 ++++++------
       Source/Modules/clisp.cxx    |  2 +-
       Source/Modules/csharp.cxx   | 17 +++++------------
       Source/Modules/guile.cxx    | 18 ++++++++++--------
       Source/Modules/java.cxx     | 29 +++++++++++-----------------
       Source/Modules/lang.cxx     | 12 ++++++++----
       Source/Modules/main.cxx     |  4 ++++
       Source/Modules/mzscheme.cxx | 16 +++++++++-------
       Source/Modules/ocaml.cxx    |  4 ++--
       Source/Modules/octave.cxx   |  4 ++--
       Source/Modules/php.cxx      |  2 +-
       Source/Modules/python.cxx   |  4 ++--
       Source/Modules/r.cxx        |  7 ++-----
       Source/Modules/ruby.cxx     |  4 ++--
       Source/Swig/cwrap.c         | 12 ++++++------
       Source/Swig/parms.c         | 19 +++++++++++++++++--
       Source/Swig/swig.h          |  3 ++-
       Source/Swig/swigparm.h      |  3 ++-
       Source/Swig/symbol.c        |  4 ++--
       Source/Swig/typemap.c       | 38 +++++++++++++++++++++++++++++++------
       Source/Swig/typeobj.c       |  6 ++++--
       27 files changed, 178 insertions(+), 106 deletions(-)
      
      diff --git a/CHANGES.current b/CHANGES.current
      index 92b882c4c..cb6c9f9c0 100644
      --- a/CHANGES.current
      +++ b/CHANGES.current
      @@ -1,6 +1,16 @@
       Version 1.3.41 (in progress)
       ============================
       
      +2010-01-03: wsfulton
      +            Fix missing file/line numbers for typemap warnings and in output from the
      +           -debug-tmsearch/-debug-tmused options.
      +
      +2010-01-03: wsfulton
      +            Add typemaps used debugging option (-debug-tmused). When used each line displays
      +            the typemap used for each type for which code is being generated including the file
      +            and line number related to the type. This is effectively a condensed form of the
      +            -debug-tmsearch option. Documented in Typemaps.html.
      +
       2009-12-23: wsfulton
                   Fix for %javaexception and directors so that all the appropriate throws clauses 
                   are generated. Problem reported by Peter Greenwood.
      diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
      index 89cae62a3..9fa487ab4 100644
      --- a/Doc/Manual/Typemaps.html
      +++ b/Doc/Manual/Typemaps.html
      @@ -1437,7 +1437,11 @@ but all subsequent arguments must match exactly.
       
       
       

      -The -debug-tmsearch command line option is available for debugging typemap searches. +There are two useful debug command line options available for debugging typemaps, -debug-tmsearch and -debug-tmused. +

      + +

      +The -debug-tmsearch option is a verbose option for debugging typemap searches. This can be very useful for watching the pattern matching process in action and for debugging which typemaps are used. The option displays all the typemaps and types that are looked for until a successful pattern match is made. As the display includes searches for each and every type needed for wrapping, the amount of information displayed can be large. @@ -1462,9 +1466,9 @@ A sample of the debugging output is shown below for the "in" typemap:

      -swig -debug-tmsearch example.i
      +swig -perl -debug-tmsearch example.i
       ...
      -example.h:26: Searching for a suitable 'in' typemap for: Row4 rows[10]
      +example.h:3: Searching for a suitable 'in' typemap for: Row4 rows[10]
         Looking for: Row4 rows[10]
         Looking for: Row4 [10]
         Looking for: Row4 rows[ANY]
      @@ -1550,6 +1554,22 @@ example.h:39: Searching for a suitable 'in' typemap for: char *buffer
       
      +

      +The second option for debugging is -debug-tmused and this displays the typemaps used. +This option is a less verbose version of the -debug-tmsearch option as it only displays each successfully found typemap on a separate single line. +The output below is for the example code at the start of this section on debugging. +

      + +
      +
      +$ swig -perl -debug-tmused example.i
      +example.h:3: Using %typemap(in) SWIGTYPE [] for: Row4 rows[10]
      +example.h:3: Using %typemap(typecheck) SWIGTYPE * for: Row4 rows[10]
      +example.h:3: Using %typemap(freearg) SWIGTYPE [] for: Row4 rows[10]
      +example.h:3: Using %typemap(out) void for: void foo
      +
      +
      +

      10.4 Code generation rules

      diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h index 9be41c60e..a71be786f 100644 --- a/Source/CParse/cparse.h +++ b/Source/CParse/cparse.h @@ -53,7 +53,7 @@ extern "C" { extern void Swig_cparse_replace_descriptor(String *s); extern void cparse_normalize_void(Node *); extern Parm *Swig_cparse_parm(String *s); - extern ParmList *Swig_cparse_parms(String *s); + extern ParmList *Swig_cparse_parms(String *s, Node *file_line_node); /* templ.c */ diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index b9db52104..dafecc96f 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -2724,11 +2724,11 @@ typemap_parm : type typemap_parameter_declarator { Parm *parm; SwigType_push($1,$2.type); $$ = new_node("typemapitem"); - parm = NewParm($1,$2.id); + parm = NewParmWithoutFileLineInfo($1,$2.id); Setattr($$,"pattern",parm); Setattr($$,"parms", $2.parms); Delete(parm); - /* $$ = NewParm($1,$2.id); + /* $$ = NewParmWithoutFileLineInfo($1,$2.id); Setattr($$,"parms",$2.parms); */ } | LPAREN parms RPAREN { @@ -3983,7 +3983,7 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN { SwigType *rtt = Swig_symbol_typedef_reduce(tt.item,0); SwigType *ttr = Swig_symbol_type_qualify(rtt,0); - Parm *newp = NewParm(ttr, 0); + Parm *newp = NewParmWithoutFileLineInfo(ttr, 0); if (partialparms) set_nextSibling(parm_current, newp); else @@ -4129,7 +4129,7 @@ templateparameters : templateparameter templateparameterstail { ; templateparameter : templcpptype { - $$ = NewParm(NewString($1), 0); + $$ = NewParmWithoutFileLineInfo(NewString($1), 0); } | parm { $$ = $1; @@ -4708,7 +4708,7 @@ ptail : COMMA parm ptail { parm : rawtype parameter_declarator { SwigType_push($1,$2.type); - $$ = NewParm($1,$2.id); + $$ = NewParmWithoutFileLineInfo($1,$2.id); Setfile($$,cparse_file); Setline($$,cparse_line); if ($2.defarg) { @@ -4717,7 +4717,7 @@ parm : rawtype parameter_declarator { } | TEMPLATE LESSTHAN cpptype GREATERTHAN cpptype idcolon def_args { - $$ = NewParm(NewStringf("template %s %s", $5,$6), 0); + $$ = NewParmWithoutFileLineInfo(NewStringf("template %s %s", $5,$6), 0); Setfile($$,cparse_file); Setline($$,cparse_line); if ($7.val) { @@ -4726,7 +4726,7 @@ parm : rawtype parameter_declarator { } | PERIOD PERIOD PERIOD { SwigType *t = NewString("v(...)"); - $$ = NewParm(t, 0); + $$ = NewParmWithoutFileLineInfo(t, 0); Setfile($$,cparse_file); Setline($$,cparse_line); } @@ -4789,7 +4789,7 @@ valparm : parm { } | valexpr { - $$ = NewParm(0,0); + $$ = NewParmWithoutFileLineInfo(0,0); Setfile($$,cparse_file); Setline($$,cparse_line); Setattr($$,"value",$1.val); @@ -6226,14 +6226,16 @@ Parm *Swig_cparse_parm(String *s) { } -ParmList *Swig_cparse_parms(String *s) { +ParmList *Swig_cparse_parms(String *s, Node *file_line_node) { String *ns; char *cs = Char(s); if (cs && cs[0] != '(') { ns = NewStringf("(%s);",s); } else { ns = NewStringf("%s;",s); - } + } + Setfile(ns, Getfile(file_line_node)); + Setline(ns, Getline(file_line_node)); Seek(ns,0,SEEK_SET); scanner_file(ns); top = 0; diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index 9cbd18d6b..c3cc115c6 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -262,7 +262,7 @@ int Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab /* Look for partial specialization matching */ if (Getattr(n, "partialargs")) { Parm *p, *tp; - ParmList *ptargs = SwigType_function_parms(Getattr(n, "partialargs")); + ParmList *ptargs = SwigType_function_parms(Getattr(n, "partialargs"), n); p = ptargs; tp = tparms; while (p && tp) { diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx index d78dd13d7..e37358be6 100644 --- a/Source/Modules/allocate.cxx +++ b/Source/Modules/allocate.cxx @@ -518,7 +518,7 @@ class Allocate:public Dispatcher { */ String *scatchlist = Getattr(n, "feature:catches"); if (scatchlist) { - catchlist = Swig_cparse_parms(scatchlist); + catchlist = Swig_cparse_parms(scatchlist, n); if (catchlist) { Setattr(n, "catchlist", catchlist); mark_exception_classes(catchlist); diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 062b9f0ff..09e97f448 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -618,12 +618,12 @@ int CFFI::enumDeclaration(Node *n) { slot_name_keywords = true; //Registering the enum name to the cin and cout typemaps - Parm *pattern = NewParm(name, NULL); + Parm *pattern = NewParm(name, NULL, n); Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL); Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL); Delete(pattern); //Registering with the kind, i.e., enum - pattern = NewParm(NewStringf("enum %s", name), NULL); + pattern = NewParm(NewStringf("enum %s", name), NULL, n); Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL); Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL); Delete(pattern); @@ -688,7 +688,7 @@ void CFFI::emit_class(Node *n) { Printf(f_clos, "\n(cl:defclass %s%s", lisp_name, supers); Printf(f_clos, "\n ((ff-pointer :reader ff-pointer)))\n\n"); - Parm *pattern = NewParm(Getattr(n, "name"), NULL); + Parm *pattern = NewParm(Getattr(n, "name"), NULL, n); Swig_typemap_register("lispclass", pattern, lisp_name, NULL, NULL); SwigType_add_pointer(Getattr(pattern, "type")); @@ -758,7 +758,7 @@ void CFFI::emit_class(Node *n) { Delete(supers); // Delete(ns_list); - // Parm *pattern = NewParm(name,NULL); + // Parm *pattern = NewParm(name, NULL, n); // Swig_typemap_register("cin",pattern,lisp_name,NULL,NULL); //Swig_typemap_register("cout",pattern,lisp_name,NULL,NULL); //Delete(pattern); @@ -787,12 +787,12 @@ void CFFI::emit_struct_union(Node *n, bool un = false) { //Register the struct/union name to the cin and cout typemaps - Parm *pattern = NewParm(name, NULL); + Parm *pattern = NewParm(name, NULL, n); Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL); Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL); Delete(pattern); //Registering with the kind, i.e., struct or union - pattern = NewParm(NewStringf("%s %s", kind, name), NULL); + pattern = NewParm(NewStringf("%s %s", kind, name), NULL, n); Swig_typemap_register("cin", pattern, lisp_name, NULL, NULL); Swig_typemap_register("cout", pattern, lisp_name, NULL, NULL); Delete(pattern); diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx index 46c5ef84a..2dc30667f 100644 --- a/Source/Modules/clisp.cxx +++ b/Source/Modules/clisp.cxx @@ -452,7 +452,7 @@ String *CLISP::get_ffi_type(Node *n, SwigType *ty) { SwigType *cp = Copy(ty); SwigType *fn = SwigType_pop_function(cp); String *args = NewString(""); - ParmList *pl = SwigType_function_parms(fn); + ParmList *pl = SwigType_function_parms(fn, n); if (ParmList_len(pl) != 0) { Printf(args, "(:arguments "); } diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 82a9a629c..7fb481271 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -86,13 +86,6 @@ class CSHARP:public Language { enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum }; - static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) { - Parm *p = NewParm(type, name); - Setfile(p, Getfile(n)); - Setline(p, Getline(n)); - return p; - } - public: /* ----------------------------------------------------------------------------- @@ -3331,7 +3324,7 @@ public: } /* Create the intermediate class wrapper */ - Parm *tp = NewParmFromNode(returntype, empty_str, n); + Parm *tp = NewParm(returntype, empty_str, n); tm = Swig_typemap_lookup("imtype", tp, "", 0); if (tm) { @@ -3351,7 +3344,7 @@ public: Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(returntype, 0)); } - Parm *retpm = NewParmFromNode(returntype, empty_str, n); + Parm *retpm = NewParm(returntype, empty_str, n); if ((c_ret_type = Swig_typemap_lookup("ctype", retpm, "", 0))) { @@ -3438,7 +3431,7 @@ public: if (ctypeout) c_param_type = ctypeout; - Parm *tp = NewParmFromNode(c_param_type, empty_str, n); + Parm *tp = NewParm(c_param_type, empty_str, n); String *desc_tm = NULL; /* Add to local variables */ @@ -3593,7 +3586,7 @@ public: String *upcall = NewStringf("%s(%s)", symname, imcall_args); if (!is_void) { - Parm *tp = NewParmFromNode(returntype, empty_str, n); + Parm *tp = NewParm(returntype, empty_str, n); if ((tm = Swig_typemap_lookup("csdirectorout", tp, "", 0))) { substituteClassname(returntype, tm); @@ -3619,7 +3612,7 @@ public: if (!is_void) { String *jresult_str = NewString("jresult"); String *result_str = NewString("c_result"); - Parm *tp = NewParmFromNode(returntype, result_str, n); + Parm *tp = NewParm(returntype, result_str, n); /* Copy jresult into c_result... */ if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) { diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 0c72de8d0..38ee7b9f5 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -1407,16 +1407,18 @@ public: } { /* Hack alert: will cleanup later -- Dave */ - Node *n = NewHash(); - Setattr(n, "name", var_name); - Setattr(n, "sym:name", iname); - Setattr(n, "type", nctype); - SetFlag(n, "feature:immutable"); + Node *nn = NewHash(); + Setfile(nn, Getfile(n)); + Setline(nn, Getline(n)); + Setattr(nn, "name", var_name); + Setattr(nn, "sym:name", iname); + Setattr(nn, "type", nctype); + SetFlag(nn, "feature:immutable"); if (constasvar) { - SetFlag(n, "feature:constasvar"); + SetFlag(nn, "feature:constasvar"); } - variableWrapper(n); - Delete(n); + variableWrapper(nn); + Delete(nn); } Delete(var_name); Delete(nctype); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index bef41b0d2..5eb6dcae9 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -83,13 +83,6 @@ class JAVA:public Language { enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum }; - static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) { - Parm *p = NewParm(type, name); - Setfile(p, Getfile(n)); - Setline(p, Getline(n)); - return p; - } - public: /* ----------------------------------------------------------------------------- @@ -1981,7 +1974,7 @@ public: if (qualifier) SwigType_push(this_type, qualifier); SwigType_add_pointer(this_type); - Parm *this_parm = NewParm(this_type, name); + Parm *this_parm = NewParm(this_type, name, n); Swig_typemap_attach_parms("jtype", this_parm, NULL); Swig_typemap_attach_parms("jstype", this_parm, NULL); @@ -3389,7 +3382,7 @@ public: } /* Create the intermediate class wrapper */ - Parm *tp = NewParmFromNode(returntype, empty_str, n); + Parm *tp = NewParm(returntype, empty_str, n); tm = Swig_typemap_lookup("jtype", tp, "", 0); if (tm) { @@ -3401,7 +3394,7 @@ public: String *cdesc = NULL; SwigType *covariant = Getattr(n, "covariant"); SwigType *adjustedreturntype = covariant ? covariant : returntype; - Parm *adjustedreturntypeparm = NewParmFromNode(adjustedreturntype, empty_str, n); + Parm *adjustedreturntypeparm = NewParm(adjustedreturntype, empty_str, n); if ((tm = Swig_typemap_lookup("directorin", adjustedreturntypeparm, "", 0)) && (cdesc = Getattr(adjustedreturntypeparm, "tmap:directorin:descriptor"))) { @@ -3421,10 +3414,10 @@ public: /* Get the JNI field descriptor for this return type, add the JNI field descriptor to jniret_desc */ - Parm *retpm = NewParmFromNode(returntype, empty_str, n); + Parm *retpm = NewParm(returntype, empty_str, n); if ((c_ret_type = Swig_typemap_lookup("jni", retpm, "", 0))) { - Parm *tp = NewParmFromNode(c_ret_type, empty_str, n); + Parm *tp = NewParm(c_ret_type, empty_str, n); if (!is_void && !ignored_method) { String *jretval_decl = NewStringf("%s jresult", c_ret_type); @@ -3526,7 +3519,7 @@ public: } /* Start the Java field descriptor for the intermediate class's upcall (insert self object) */ - Parm *tp = NewParmFromNode(c_classname, empty_str, n); + Parm *tp = NewParm(c_classname, empty_str, n); String *jdesc; if ((tm = Swig_typemap_lookup("directorin", tp, "", 0)) @@ -3568,7 +3561,7 @@ public: /* Get parameter's intermediary C type */ if ((c_param_type = Getattr(p, "tmap:jni"))) { - Parm *tp = NewParmFromNode(c_param_type, empty_str, n); + Parm *tp = NewParm(c_param_type, empty_str, n); String *desc_tm = NULL, *jdesc = NULL, *cdesc = NULL; /* Add to local variables */ @@ -3728,7 +3721,7 @@ public: addThrows(n, "feature:except", n); if (!is_void) { - Parm *tp = NewParmFromNode(returntype, empty_str, n); + Parm *tp = NewParm(returntype, empty_str, n); if ((tm = Swig_typemap_lookup("javadirectorout", tp, "", 0))) { addThrows(n, "tmap:javadirectorout", tp); @@ -3772,7 +3765,7 @@ public: if (!is_void) { String *jresult_str = NewString("jresult"); String *result_str = NewString("c_result"); - Parm *tp = NewParmFromNode(returntype, result_str, n); + Parm *tp = NewParm(returntype, result_str, n); /* Copy jresult into c_result... */ if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) { @@ -3865,7 +3858,7 @@ public: SwigType_add_pointer(jenv_type); - p = NewParmFromNode(jenv_type, NewString("jenv"), n); + p = NewParm(jenv_type, NewString("jenv"), n); Setattr(p, "arg:byname", "1"); set_nextSibling(p, NULL); @@ -3902,7 +3895,7 @@ public: String *jenv_type = NewString("JNIEnv"); SwigType_add_pointer(jenv_type); - p = NewParmFromNode(jenv_type, NewString("jenv"), n); + p = NewParm(jenv_type, NewString("jenv"), n); set_nextSibling(p, parms); parms = p; diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 971b56ec1..ea1f09133 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -900,7 +900,7 @@ int Language::cDeclaration(Node *n) { Delete(ty); ty = fullty; fullty = 0; - ParmList *parms = SwigType_function_parms(ty); + ParmList *parms = SwigType_function_parms(ty, n); Setattr(n, "parms", parms); } /* Transform the node into a 'function' node and emit */ @@ -1188,6 +1188,8 @@ int Language::memberfunctionHandler(Node *n) { Setattr(cbn, "type", cbty); Setattr(cbn, "value", cbvalue); Setattr(cbn, "name", name); + Setfile(cbn, Getfile(n)); + Setline(cbn, Getline(n)); memberconstantHandler(cbn); Setattr(n, "feature:callback:name", Swig_name_member(ClassPrefix, cbname)); @@ -1478,7 +1480,7 @@ int Language::membervariableHandler(Node *n) { Parm *p; String *gname; SwigType *vty; - p = NewParm(type, 0); + p = NewParm(type, 0, n); gname = NewStringf(AttributeFunctionGet, symname); if (!Extend) { ActionFunc = Copy(Swig_cmemberget_call(name, type)); @@ -1904,12 +1906,14 @@ int Language::classDirectorDisown(Node *n) { String *type = NewString(ClassType); String *name = NewString("self"); SwigType_add_pointer(type); - Parm *p = NewParm(type, name); + Parm *p = NewParm(type, name, n); Delete(name); Delete(type); type = NewString("void"); String *action = NewString(""); Printv(action, "{\n", "Swig::Director *director = dynamic_cast(arg1);\n", "if (director) director->swig_disown();\n", "}\n", NULL); + Setfile(disown, Getfile(n)); + Setline(disown, Getline(n)); Setattr(disown, "wrap:action", action); Setattr(disown, "name", mrename); Setattr(disown, "sym:name", mrename); @@ -2162,7 +2166,7 @@ static void addCopyConstructor(Node *n) { if (!symname) { symname = Copy(csymname); } - Parm *p = NewParm(cc, "other"); + Parm *p = NewParm(cc, "other", n); Setattr(cn, "name", name); Setattr(cn, "sym:name", symname); diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 9194d39a0..34914efa3 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -71,6 +71,7 @@ static const char *usage1 = (const char *) "\ -debug-typedef - Display information about the types and typedefs in the interface\n\ -debug-typemap - Display typemap debugging information\n\ -debug-tmsearch - Display typemap search debugging information\n\ + -debug-tmused - Display typemaps used debugging information\n\ -directors - Turn on director mode for all the classes, mainly for testing\n\ -dirprot - Turn on wrapping of protected members for director classes (default)\n\ -D - Define a symbol (for conditional compilation)\n\ @@ -659,6 +660,9 @@ void SWIG_getoptions(int argc, char *argv[]) { } else if (strcmp(argv[i], "-debug-tmsearch") == 0) { Swig_typemap_search_debug_set(); Swig_mark_arg(i); + } else if (strcmp(argv[i], "-debug-tmused") == 0) { + Swig_typemap_used_debug_set(); + Swig_mark_arg(i); } else if (strcmp(argv[i], "-module") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index 28dd8ecd2..77339d325 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -647,13 +647,15 @@ public: { /* Hack alert: will cleanup later -- Dave */ - Node *n = NewHash(); - Setattr(n, "name", var_name); - Setattr(n, "sym:name", iname); - Setattr(n, "type", type); - SetFlag(n, "feature:immutable"); - variableWrapper(n); - Delete(n); + Node *nn = NewHash(); + Setfile(nn, Getfile(n)); + Setline(nn, Getline(n)); + Setattr(nn, "name", var_name); + Setattr(nn, "sym:name", iname); + Setattr(nn, "type", type); + SetFlag(nn, "feature:immutable"); + variableWrapper(nn); + Delete(nn); } } Delete(proc_name); diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index 8a797759c..cfd4fc682 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1727,7 +1727,7 @@ public: ParmList *superparms = Getattr(n, "parms"); ParmList *parms = CopyParmList(superparms); String *type = NewString("CAML_VALUE"); - p = NewParm(type, NewString("self")); + p = NewParm(type, NewString("self"), n); q = Copy(p); set_nextSibling(q, superparms); set_nextSibling(p, parms); @@ -1780,7 +1780,7 @@ public: ParmList *superparms = Getattr(n, "parms"); ParmList *parms = CopyParmList(superparms); String *type = NewString("CAML_VALUE"); - p = NewParm(type, NewString("self")); + p = NewParm(type, NewString("self"), n); q = Copy(p); set_nextSibling(p, parms); parms = p; diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index 1804334d6..ff880fc5a 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -956,7 +956,7 @@ public: String *name = NewString("self"); String *type = NewString("void"); SwigType_add_pointer(type); - self = NewParm(type, name); + self = NewParm(type, name, n); Delete(type); Delete(name); Setattr(self, "lname", "self_obj"); @@ -1051,7 +1051,7 @@ public: ParmList *parms = CopyParmList(superparms); String *type = NewString("void"); SwigType_add_pointer(type); - p = NewParm(type, NewString("self")); + p = NewParm(type, NewString("self"), n); set_nextSibling(p, parms); parms = p; diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index ca9d4e742..e98a16f7d 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -2323,7 +2323,7 @@ done: ParmList *parms = CopyParmList(superparms); String *type = NewString("zval"); SwigType_add_pointer(type); - p = NewParm(type, NewString("self")); + p = NewParm(type, NewString("self"), n); set_nextSibling(p, parms); parms = p; diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 9475139a3..bc76f17d4 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -2625,7 +2625,7 @@ public: ParmList *parms = CopyParmList(superparms); String *type = NewString("PyObject"); SwigType_add_pointer(type); - p = NewParm(type, NewString("self")); + p = NewParm(type, NewString("self"), n); set_nextSibling(p, parms); parms = p; @@ -3205,7 +3205,7 @@ public: String *name = NewString("self"); String *type = NewString("PyObject"); SwigType_add_pointer(type); - self = NewParm(type, name); + self = NewParm(type, name, n); Delete(type); Delete(name); Setattr(self, "lname", "O"); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 41058284f..fec2330bd 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -588,7 +588,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { // ParmList *parms = Getattr(n, "parms"); // memory leak - ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t))); + ParmList *parms = SwigType_function_parms(SwigType_del_pointer(Copy(t)), n); // if (debugMode) { @@ -712,10 +712,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) { XXX Have to be a little more clever so that we can deal with struct A * - the * is getting lost. Is this still true? If so, will a SwigType_push() solve things? */ - Node *bbase = NewHash(); - - Setattr(bbase, "type", rettype); - Setattr(bbase, "name", NewString("result")); + Parm *bbase = NewParm(rettype, "result", n); String *returnTM = Swig_typemap_lookup("in", bbase, "result", f); if(returnTM) { String *tm = returnTM; diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 8d5ab4fae..a28256753 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2590,7 +2590,7 @@ public: Parm *self; String *name = NewString("self"); String *type = NewString("VALUE"); - self = NewParm(type, name); + self = NewParm(type, name, n); Delete(type); Delete(name); Setattr(self, "lname", "Qnil"); @@ -2812,7 +2812,7 @@ public: ParmList *superparms = Getattr(n, "parms"); ParmList *parms = CopyParmList(superparms); String *type = NewString("VALUE"); - p = NewParm(type, NewString("self")); + p = NewParm(type, NewString("self"), n); set_nextSibling(p, parms); parms = p; diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 7b2646b0e..f4c925206 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -803,7 +803,7 @@ int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *direc SwigType_push(type, qualifier); } SwigType_add_pointer(type); - p = NewParm(type, "self"); + p = NewParm(type, "self", n); Setattr(p, "self", "1"); Setattr(p, "hidden","1"); /* @@ -1155,7 +1155,7 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags) type = NewString(classname); SwigType_add_pointer(type); - p = NewParm(type, "self"); + p = NewParm(type, "self", n); Setattr(p, "self", "1"); Setattr(p, "hidden", "1"); Setattr(p, "wrap:disown", "1"); @@ -1238,13 +1238,13 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) { t = NewString(classname); SwigType_add_pointer(t); - parms = NewParm(t, "self"); + parms = NewParm(t, "self", n); Setattr(parms, "self", "1"); Setattr(parms, "hidden","1"); Delete(t); ty = Swig_wrapped_member_var_type(type, varcref); - p = NewParm(ty, name); + p = NewParm(ty, name, n); Setattr(parms, "hidden", "1"); set_nextSibling(parms, p); @@ -1327,7 +1327,7 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) { t = NewString(classname); SwigType_add_pointer(t); - parms = NewParm(t, "self"); + parms = NewParm(t, "self", n); Setattr(parms, "self", "1"); Setattr(parms, "hidden","1"); Delete(t); @@ -1383,7 +1383,7 @@ int Swig_VarsetToFunction(Node *n, int flags) { type = Getattr(n, "type"); nname = SwigType_namestr(name); ty = Swig_wrapped_var_type(type, varcref); - parms = NewParm(ty, name); + parms = NewParm(ty, name, n); if (flags & CWRAP_EXTEND) { String *sname = Swig_name_set(name); diff --git a/Source/Swig/parms.c b/Source/Swig/parms.c index 6b0863ee4..494599adb 100644 --- a/Source/Swig/parms.c +++ b/Source/Swig/parms.c @@ -14,10 +14,25 @@ char cvsroot_parms_c[] = "$Id$"; /* ------------------------------------------------------------------------ * NewParm() * - * Create a new parameter from datatype 'type' and name 'name'. + * Create a new parameter from datatype 'type' and name 'name' copying + * the file and line number from the Node file_line_node. * ------------------------------------------------------------------------ */ -Parm *NewParm(SwigType *type, const_String_or_char_ptr name) { +Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *file_line_node) { + Parm *p = NewParmWithoutFileLineInfo(type, name); + Setfile(p, Getfile(file_line_node)); + Setline(p, Getline(file_line_node)); + return p; +} + +/* ------------------------------------------------------------------------ + * NewParmWithoutFileLineInfo() + * + * Create a new parameter from datatype 'type' and name 'name' without any + * file / line numbering information. + * ------------------------------------------------------------------------ */ + +Parm *NewParmWithoutFileLineInfo(SwigType *type, const_String_or_char_ptr name) { Parm *p = NewHash(); set_nodeType(p, "parm"); if (type) { diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 8c4d50000..3e7ae8c38 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -123,7 +123,7 @@ extern "C" { extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms); extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms); extern SwigType *SwigType_pop_function(SwigType *t); - extern ParmList *SwigType_function_parms(SwigType *t); + extern ParmList *SwigType_function_parms(SwigType *t, Node *file_line_node); extern List *SwigType_split(const SwigType *t); extern String *SwigType_pop(SwigType *t); extern void SwigType_push(SwigType *t, SwigType *s); @@ -371,6 +371,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Swig_typemap_clear_apply(ParmList *pattern); extern void Swig_typemap_debug(void); extern void Swig_typemap_search_debug_set(void); + extern void Swig_typemap_used_debug_set(void); extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f); extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode); diff --git a/Source/Swig/swigparm.h b/Source/Swig/swigparm.h index 49ae7992e..d1209a5b2 100644 --- a/Source/Swig/swigparm.h +++ b/Source/Swig/swigparm.h @@ -11,7 +11,8 @@ /* $Id: swig.h 9629 2006-12-30 18:27:47Z beazley $ */ /* Individual parameters */ -extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name); +extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *file_line_node); +extern Parm *NewParmWithoutFileLineInfo(SwigType *type, const_String_or_char_ptr name); extern Parm *CopyParm(Parm *p); /* Parameter lists */ diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index b5ed37c0c..e018029a1 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -1807,7 +1807,7 @@ ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, ntq = ty; } /* Printf(stderr,"value %s %s %s\n",value,ntr,ntq); */ - cp = NewParm(ntq, 0); + cp = NewParmWithoutFileLineInfo(ntq, 0); if (lp) set_nextSibling(lp, cp); else @@ -1884,7 +1884,7 @@ SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope) { String *tprefix = SwigType_templateprefix(base); String *targs = SwigType_templateargs(base); String *tsuffix = SwigType_templatesuffix(base); - ParmList *tparms = SwigType_function_parms(targs); + ParmList *tparms = SwigType_function_parms(targs, 0); Node *tempn = Swig_symbol_clookup_local(tprefix, tscope); if (!tempn && tsuffix && Len(tsuffix)) { tempn = Swig_symbol_clookup(tprefix, 0); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 3bb4e6909..a912b4948 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -18,9 +18,10 @@ char cvsroot_typemap_c[] = "$Id$"; #endif static int typemap_search_debug = 0; +static int typemaps_used_debug = 0; static int in_typemap_search_multi = 0; -static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f); +static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f, Node *file_line_node); /* ----------------------------------------------------------------------------- * Typemaps are stored in a collection of nested hash tables. Something like @@ -266,6 +267,8 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par else typemap = NewStringf("typemap(%s) %s", actual_tmap_method, parms_str); + Setfile(tm2, Getfile(code)); + Setline(tm2, Getline(code)); Setattr(tm2, "code", code); Setattr(tm2, "type", type); Setattr(tm2, "typemap", typemap); @@ -871,6 +874,12 @@ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList if (typemap_search_debug && (in_typemap_search_multi == 0)) debug_search_result_display(tm); + if (typemaps_used_debug && tm) { + String *typestr = SwigType_str(type, name); + Swig_diagnostic(Getfile(parms), Getline(parms), "Using %%%s for: %s\n", Getattr(tm, "typemap"), typestr); + assert(Getfile(parms) && Len(Getfile(parms)) > 0); /* Missing file and line numbering information */ + Delete(typestr); + } return tm; } @@ -1345,6 +1354,13 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No tm = typemap_search(tmap_method, type, pname, qpname, &mtype, node); if (typemap_search_debug) debug_search_result_display(tm); + if (typemaps_used_debug && tm) { + String *typestr = SwigType_str(type, qpname ? qpname : pname); + Swig_diagnostic(Getfile(node), Getline(node), "Using %%%s for: %s\n", Getattr(tm, "typemap"), typestr); + assert(Getfile(node) && Len(Getfile(node)) > 0); /* Missing file and line numbering information */ + Delete(typestr); + } + Delete(qpname); qpname = 0; @@ -1450,9 +1466,9 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No } { - ParmList *parm_sublist = NewParm(type, pname); + ParmList *parm_sublist = NewParmWithoutFileLineInfo(type, pname); Setattr(parm_sublist, "lname", lname); - replace_embedded_typemap(s, parm_sublist, f); + replace_embedded_typemap(s, parm_sublist, f, tm); Delete(parm_sublist); } @@ -1730,7 +1746,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p typemap_locals(s, locals, f, argnum); } - replace_embedded_typemap(s, firstp, f); + replace_embedded_typemap(s, firstp, f, tm); /* Replace the argument number */ sprintf(temp, "%d", argnum); @@ -1851,7 +1867,7 @@ static List *split_embedded_typemap(String *s) { * $typemap(in, (Foo a, int b)) # multi-argument typemap matching %typemap(in) (Foo a, int b) {...} * ----------------------------------------------------------------------------- */ -static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f) { +static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f, Node *file_line_node) { char *start = 0; while ((start = strstr(Char(s), "$TYPEMAP("))) { /* note $typemap capitalisation to $TYPEMAP hack */ @@ -1895,7 +1911,7 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper /* the second parameter might contain multiple sub-parameters for multi-argument * typemap matching, so split these parameters apart */ - to_match_parms = Swig_cparse_parms(Getitem(l, 1)); + to_match_parms = Swig_cparse_parms(Getitem(l, 1), file_line_node); if (to_match_parms) { Parm *p = to_match_parms; Parm *sub_p = parm_sublist; @@ -2029,3 +2045,13 @@ void Swig_typemap_search_debug_set(void) { typemap_search_debug = 1; } +/* ----------------------------------------------------------------------------- + * Swig_typemap_used_debug_set() + * + * Turn on typemaps used debug display + * ----------------------------------------------------------------------------- */ + +void Swig_typemap_used_debug_set(void) { + typemaps_used_debug = 1; +} + diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index 8ff31bc0b..cbc2fd414 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -781,13 +781,15 @@ int SwigType_isfunction(SwigType *t) { return 0; } -ParmList *SwigType_function_parms(SwigType *t) { +/* Create a list of parameters from the type t, using the file_line_node Node for + * file and line numbering for the parameters */ +ParmList *SwigType_function_parms(SwigType *t, Node *file_line_node) { List *l = SwigType_parmlist(t); Hash *p, *pp = 0, *firstp = 0; Iterator o; for (o = First(l); o.item; o = Next(o)) { - p = NewParm(o.item, 0); + p = file_line_node ? NewParm(o.item, 0, file_line_node) : NewParmWithoutFileLineInfo(o.item, 0); if (!firstp) firstp = p; if (pp) { From b1ad69ade542140409fde0244585908f02eedee7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 5 Jan 2010 23:24:47 +0000 Subject: [PATCH 296/352] Fix -debug-tmsearch and -debug-tmused to show tthat the typemap came from a typemap copy or %apply git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11803 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/parms.c | 18 +++++++++++++ Source/Swig/swigparm.h | 1 + Source/Swig/typemap.c | 58 +++++++++++++++++++++++++----------------- 3 files changed, 54 insertions(+), 23 deletions(-) diff --git a/Source/Swig/parms.c b/Source/Swig/parms.c index 494599adb..90a072a7e 100644 --- a/Source/Swig/parms.c +++ b/Source/Swig/parms.c @@ -183,6 +183,24 @@ String *ParmList_str_defaultargs(ParmList *p) { return out; } +/* ----------------------------------------------------------------------------- + * ParmList_str_multibrackets() + * + * Generates a string of parameters including default arguments adding brackets + * if more than one parameter + * ----------------------------------------------------------------------------- */ + +String *ParmList_str_multibrackets(ParmList *p) { + String *out; + String *parm_str = ParmList_str_defaultargs(p); + if (ParmList_len(p) > 1) + out = NewStringf("(%s)", parm_str); + else + out = NewStringf("%s", parm_str); + Delete(parm_str); + return out; +} + /* --------------------------------------------------------------------- * ParmList_protostr() * diff --git a/Source/Swig/swigparm.h b/Source/Swig/swigparm.h index d1209a5b2..4a928999e 100644 --- a/Source/Swig/swigparm.h +++ b/Source/Swig/swigparm.h @@ -25,6 +25,7 @@ extern int ParmList_has_defaultargs(ParmList *p); /* Output functions */ extern String *ParmList_str(ParmList *); extern String *ParmList_str_defaultargs(ParmList *); +extern String *ParmList_str_multibrackets(ParmList *); extern String *ParmList_protostr(ParmList *); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index a912b4948..2a77bb06f 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -40,7 +40,7 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper * "type" - Typemap type * "pname" - Parameter name * "code" - Typemap code - * "typemap" - Descriptive text describing the actual map + * "source" - Source directive (%apply or %typemap) for the typemap * "locals" - Local variables (if any) * "kwargs" - Typemap attributes * @@ -50,7 +50,7 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper * "type" - r.int * "pname" - my_int * "code" - $1 = $input; - * "typemap" - typemap(in) int &my_int + * "source" - typemap(in) int &my_int * "locals" - int tmp * "kwargs" - warning="987:my typemap warning", foo=123 * @@ -180,7 +180,7 @@ Hash *Swig_typemap_pop_scope() { * Internal implementation for Swig_typemap_register() * ----------------------------------------------------------------------------- */ -static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs, const_String_or_char_ptr actual_tmap_method, ParmList *parmlist_start) { +static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs, String *source_directive) { Hash *tm; Hash *tm1; Hash *tm2; @@ -252,26 +252,20 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par if (np) { /* Make an entirely new typemap method key */ String *multi_tmap_method = NewStringf("%s-%s+%s:", tmap_method, type, pname); - /* Now reregister on the remaining arguments */ - typemap_register(multi_tmap_method, np, code, locals, kwargs, actual_tmap_method, parmlist_start); - /* Setattr(tm2,multi_tmap_method,multi_tmap_method); */ + /* Now reregister on the remaining arguments */ + typemap_register(multi_tmap_method, np, code, locals, kwargs, source_directive); + Delete(multi_tmap_method); } else { ParmList *clocals = CopyParmList(locals); ParmList *ckwargs = CopyParmList(kwargs); - String *parms_str = ParmList_str(parmlist_start); - String *typemap; - if (ParmList_len(parmlist_start) > 1) - typemap = NewStringf("typemap(%s) (%s)", actual_tmap_method, parms_str); - else - typemap = NewStringf("typemap(%s) %s", actual_tmap_method, parms_str); Setfile(tm2, Getfile(code)); Setline(tm2, Getline(code)); Setattr(tm2, "code", code); Setattr(tm2, "type", type); - Setattr(tm2, "typemap", typemap); + Setattr(tm2, "source", source_directive); if (pname) { Setattr(tm2, "pname", pname); } @@ -280,9 +274,6 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par Delete(clocals); Delete(ckwargs); - - Delete(parms_str); - Delete(typemap); } } @@ -293,7 +284,13 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par * ----------------------------------------------------------------------------- */ void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) { - typemap_register(tmap_method, parms, code, locals, kwargs, tmap_method, parms); + String *parms_str = ParmList_str_multibrackets(parms); + String *source_directive = NewStringf("typemap(%s) %s", tmap_method, parms_str); + + typemap_register(tmap_method, parms, code, locals, kwargs, source_directive); + + Delete(source_directive); + Delete(parms_str); } /* ----------------------------------------------------------------------------- @@ -361,9 +358,16 @@ int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcparms, Delete(tm_methods); if (!p && tm) { - /* Got some kind of match */ - Swig_typemap_register(tmap_method, parms, Getattr(tm, "code"), Getattr(tm, "locals"), Getattr(tm, "kwargs")); + String *parms_str = ParmList_str_multibrackets(parms); + String *srcparms_str = ParmList_str_multibrackets(srcparms); + String *source_directive = NewStringf("typemap(%s) %s = %s", tmap_method, parms_str, srcparms_str); + + typemap_register(tmap_method, parms, Getattr(tm, "code"), Getattr(tm, "locals"), Getattr(tm, "kwargs"), source_directive); + + Delete(source_directive); + Delete(srcparms_str); + Delete(parms_str); return 0; } ts--; @@ -529,9 +533,17 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) { locals = Getattr(sm1, "locals"); kwargs = Getattr(sm1, "kwargs"); if (code) { + String *src_str = ParmList_str_multibrackets(src); + String *dest_str = ParmList_str_multibrackets(dest); + String *source_directive = NewStringf("apply %s { %s }", src_str, dest_str); + Replace(nkey, dsig, "", DOH_REPLACE_ANY); Replace(nkey, "tmap:", "", DOH_REPLACE_ANY); - Swig_typemap_register(nkey, dest, code, locals, kwargs); + typemap_register(nkey, dest, code, locals, kwargs, source_directive); + + Delete(source_directive); + Delete(dest_str); + Delete(src_str); } } Delete(nkey); @@ -616,7 +628,7 @@ static SwigType *strip_arrays(SwigType *type) { static void debug_search_result_display(Node *tm) { if (tm) - Printf(stdout, " Using: %%%s\n", Getattr(tm, "typemap")); + Printf(stdout, " Using: %%%s\n", Getattr(tm, "source")); else Printf(stdout, " None found\n"); } @@ -876,7 +888,7 @@ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList debug_search_result_display(tm); if (typemaps_used_debug && tm) { String *typestr = SwigType_str(type, name); - Swig_diagnostic(Getfile(parms), Getline(parms), "Using %%%s for: %s\n", Getattr(tm, "typemap"), typestr); + Swig_diagnostic(Getfile(parms), Getline(parms), "Using %%%s for: %s\n", Getattr(tm, "source"), typestr); assert(Getfile(parms) && Len(Getfile(parms)) > 0); /* Missing file and line numbering information */ Delete(typestr); } @@ -1356,7 +1368,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No debug_search_result_display(tm); if (typemaps_used_debug && tm) { String *typestr = SwigType_str(type, qpname ? qpname : pname); - Swig_diagnostic(Getfile(node), Getline(node), "Using %%%s for: %s\n", Getattr(tm, "typemap"), typestr); + Swig_diagnostic(Getfile(node), Getline(node), "Using %%%s for: %s\n", Getattr(tm, "source"), typestr); assert(Getfile(node) && Len(Getfile(node)) > 0); /* Missing file and line numbering information */ Delete(typestr); } From 65a52707f0e7860e24a62c455cfd7edf04d3d1f1 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 5 Jan 2010 23:44:42 +0000 Subject: [PATCH 297/352] Minor fix for -debug-tmused and multi-argument typemaps git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11804 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/typemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 2a77bb06f..e27b44f24 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -886,7 +886,7 @@ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList if (typemap_search_debug && (in_typemap_search_multi == 0)) debug_search_result_display(tm); - if (typemaps_used_debug && tm) { + if (typemaps_used_debug && (in_typemap_search_multi == 0) && tm) { String *typestr = SwigType_str(type, name); Swig_diagnostic(Getfile(parms), Getline(parms), "Using %%%s for: %s\n", Getattr(tm, "source"), typestr); assert(Getfile(parms) && Len(Getfile(parms)) > 0); /* Missing file and line numbering information */ From eb2e4a59d02a98be13aab1cb040c64cec8bb177d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 8 Jan 2010 08:09:41 +0000 Subject: [PATCH 298/352] minor tidy up git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11805 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/typemap.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index e27b44f24..86688b153 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -662,11 +662,9 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type ts = tm_scope; if (debug_display) { - String *empty_string = NewStringEmpty(); - String *typestr = SwigType_str(type, cqualifiedname ? cqualifiedname : (cname ? cname : empty_string)); + String *typestr = SwigType_str(type, cqualifiedname ? cqualifiedname : cname); Swig_diagnostic(Getfile(node), Getline(node), "Searching for a suitable '%s' typemap for: %s\n", tmap_method, typestr); Delete(typestr); - Delete(empty_string); } while (ts >= 0) { ctype = type; @@ -824,15 +822,12 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type result = backup; ret_result: - if (noarrays) - Delete(noarrays); - if (primitive) - Delete(primitive); + Delete(noarrays); + Delete(primitive); if ((unstripped) && (unstripped != type)) Delete(unstripped); - if (matchtype) { + if (matchtype) *matchtype = Copy(ctype); - } if (type != ctype) Delete(ctype); return result; From d82621ca351e00f2fb5817ab89c3391cc03df325 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 8 Jan 2010 18:42:31 +0000 Subject: [PATCH 299/352] Fix SwigType_str so that should the name contain type information it is displayed correctly - noticeable in -debug-tmsearch and -debug-tmused git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11806 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/stype.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index aa5d448a3..707232558 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -550,7 +550,10 @@ String *SwigType_str(SwigType *s, const_String_or_char_ptr id) { int nelements, i; if (id) { - result = NewString(id); + /* stringify the id expanding templates, for example when the id is a fully qualified templated class name */ + String *id_str = NewString(id); /* unfortunate copy due to current const limitations */ + result = SwigType_str(id_str, 0); + Delete(id_str); } else { result = NewStringEmpty(); } From ff1cc536a5883f1bbfeb0a8005a0874e1dbccfb6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 8 Jan 2010 18:46:41 +0000 Subject: [PATCH 300/352] Very minor perf tweak git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11807 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/mzscheme.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index 77339d325..1641b719a 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -764,7 +764,7 @@ public: Printv(access_mem, "(ptr)->", name, NIL); if ((SwigType_type(type) == T_USER) && (!is_a_pointer(type))) { Printv(convert_tab, tab4, "fields[i++] = ", NIL); - Printv(convert_tab, "_swig_convert_struct_", swigtype, "((", SwigType_str(ctype_ptr, ""), ")&((ptr)->", name, "));\n", NIL); + Printv(convert_tab, "_swig_convert_struct_", swigtype, "((", SwigType_str(ctype_ptr, 0), ")&((ptr)->", name, "));\n", NIL); } else if ((tm = Swig_typemap_lookup("varout", n, access_mem, 0))) { Replaceall(tm, "$result", "fields[i++]"); Printv(convert_tab, tm, "\n", NIL); From 0f93753a082caa669962a3b9d1f24265ce5d43d7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 9 Jan 2010 00:24:25 +0000 Subject: [PATCH 301/352] Improve -debug-tmused output so that the typemap method name is always shown - it was missing when the typemap came from a %apply. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11808 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Typemaps.html | 77 ++++++++++++++++++++++++++++++++++++---- Source/Swig/typemap.c | 4 +-- 2 files changed, 72 insertions(+), 9 deletions(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 9fa487ab4..cd4c074f1 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -681,8 +681,9 @@ these methods is described later.

      -modifiers is an optional comma separated list of name="value" values. These -are sometimes to attach extra information to a typemap and is often target-language dependent. +modifiers is an optional comma separated list of name="value" values. +These are sometimes to attach extra information to a typemap and is often target-language dependent. +They are also known as typemap attributes.

      @@ -1557,19 +1558,81 @@ example.h:39: Searching for a suitable 'in' typemap for: char *buffer

      The second option for debugging is -debug-tmused and this displays the typemaps used. This option is a less verbose version of the -debug-tmsearch option as it only displays each successfully found typemap on a separate single line. -The output below is for the example code at the start of this section on debugging. +The output displays the type, and name if present, the typemap method in brackets and then the actual typemap used. +Below is the output for the example code at the start of this section on debugging.

       $ swig -perl -debug-tmused example.i
      -example.h:3: Using %typemap(in) SWIGTYPE [] for: Row4 rows[10]
      -example.h:3: Using %typemap(typecheck) SWIGTYPE * for: Row4 rows[10]
      -example.h:3: Using %typemap(freearg) SWIGTYPE [] for: Row4 rows[10]
      -example.h:3: Using %typemap(out) void for: void foo
      +example.h:3: Typemap for Row4 rows[10] (in) : %typemap(in) SWIGTYPE []
      +example.h:3: Typemap for Row4 rows[10] (typecheck) : %typemap(typecheck) SWIGTYPE *
      +example.h:3: Typemap for Row4 rows[10] (freearg) : %typemap(freearg) SWIGTYPE []
      +example.h:3: Typemap for void foo (out) : %typemap(out) void
       
      +

      +Now, consider the following interface file: +

      + +
      +
      +%module example
      +
      +%{
      +void set_value(const char* val) {}
      +%}
      +
      +%typemap(check) char *NON_NULL {
      +  if (!$1) {
      +    /* ... error handling ... */
      +  }
      +}
      +
      +%apply SWIGTYPE * { const char* val, const char* another_value } // use default pointer handling instead of strings
      +
      +%typemap(check) const char* val = char* NON_NULL;
      +
      +%typemap(arginit, noblock=1) const char* val {
      +   $1 = "";
      +}
      +
      +void set_value(const char* val);
      +
      +
      +
      + +

      +and the output debug: +

      + +
      +
      +swig -perl5 -debug-tmused example.i
      +example.i:21: Typemap for char const *val (arginit) : %typemap(arginit) char const *val
      +example.i:21: Typemap for char const *val (in) : %apply SWIGTYPE * { char const *val }
      +example.i:21: Typemap for char const *val (typecheck) : %apply SWIGTYPE * { char const *val }
      +example.i:21: Typemap for char const *val (check) : %typemap(check) char const *val = char *NON_NULL
      +example.i:21: Typemap for char const *val (freearg) : %apply SWIGTYPE * { char const *val }
      +example.i:21: Typemap for void set_value (out) : %typemap(out) void
      +
      +
      + +

      +The following observations about what is displayed can be noted (the same applies for -debug-tmsearch): +

    101. +The relevant typemap is shown, but for typemap copying, the appropriate %typemap or %apply is displayed, for example, the "check" and "in" typemaps. +
    102. +
    103. +The typemap modifiers are not shown, eg the noblock=1 modifier in the "arginit" typemap. +
    104. +
    105. +The exact %apply statement might look different to what is in the actual code. For example, the const char* another_value is not shown as it is not relevant here. +Also the types may be displayed slightly differently - char const * and not const char*. +
    106. +

      +

      10.4 Code generation rules

      diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 86688b153..f0bf9eef3 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -883,7 +883,7 @@ static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList debug_search_result_display(tm); if (typemaps_used_debug && (in_typemap_search_multi == 0) && tm) { String *typestr = SwigType_str(type, name); - Swig_diagnostic(Getfile(parms), Getline(parms), "Using %%%s for: %s\n", Getattr(tm, "source"), typestr); + Swig_diagnostic(Getfile(parms), Getline(parms), "Typemap for %s (%s) : %%%s\n", typestr, tmap_method, Getattr(tm, "source")); assert(Getfile(parms) && Len(Getfile(parms)) > 0); /* Missing file and line numbering information */ Delete(typestr); } @@ -1363,7 +1363,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No debug_search_result_display(tm); if (typemaps_used_debug && tm) { String *typestr = SwigType_str(type, qpname ? qpname : pname); - Swig_diagnostic(Getfile(node), Getline(node), "Using %%%s for: %s\n", Getattr(tm, "source"), typestr); + Swig_diagnostic(Getfile(node), Getline(node), "Typemap for %s (%s) : %%%s\n", typestr, tmap_method, Getattr(tm, "source")); assert(Getfile(node) && Len(Getfile(node)) > 0); /* Missing file and line numbering information */ Delete(typestr); } From 1b3ca38023342b017f009c5e3f4f025497faa5ff Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 9 Jan 2010 00:42:01 +0000 Subject: [PATCH 302/352] Slight change to warning, error and diagnostic reporting. The warning number is no longer shown within brackets. This is to help default parsing of warning messages by other tools, vim on Unix in particular. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11809 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 12 ++++++++++++ Source/Swig/error.c | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index cb6c9f9c0..2016a1e53 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,18 @@ Version 1.3.41 (in progress) ============================ +2010-01-09: wsfulton + Slight change to warning, error and diagnostic reporting. The warning number is no + longer shown within brackets. This is to help default parsing of warning messages by + other tools, vim on Unix in particular. + + Example original display using -Fstandard: + example.i:20: Warning(401): Nothing known about base class 'B'. Ignored. + New display: + example.i:20: Warning 401: Nothing known about base class 'B'. Ignored. + + *** POTENTIAL INCOMPATIBILITY *** + 2010-01-03: wsfulton Fix missing file/line numbers for typemap warnings and in output from the -debug-tmsearch/-debug-tmused options. diff --git a/Source/Swig/error.c b/Source/Swig/error.c index 0f4728954..48a54f1d3 100644 --- a/Source/Swig/error.c +++ b/Source/Swig/error.c @@ -256,7 +256,7 @@ void Swig_error_msg_format(ErrorMessageFormat format) { fmt_eof = "%s:EOF"; } - sprintf(wrn_wnum_fmt, "%s: %s(%%d): ", fmt_line, warning); + sprintf(wrn_wnum_fmt, "%s: %s %%d: ", fmt_line, warning); sprintf(wrn_nnum_fmt, "%s: %s: ", fmt_line, warning); sprintf(err_line_fmt, "%s: %s: ", fmt_line, error); sprintf(err_eof_fmt, "%s: %s: ", fmt_eof, error); From 43e07da0f645e364e8f8d49ec0b86e5bf0d2b1d4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 9 Jan 2010 00:56:02 +0000 Subject: [PATCH 303/352] Update warnings to newer slightly modified warning format git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11810 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/CSharp.html | 2 +- Doc/Manual/Java.html | 2 +- Doc/Manual/Lua.html | 2 +- Doc/Manual/Modules.html | 2 +- Doc/Manual/Python.html | 2 +- Doc/Manual/Ruby.html | 4 ++-- Doc/Manual/SWIGPlus.html | 8 ++++---- Doc/Manual/Tcl.html | 2 +- Doc/Manual/Typemaps.html | 4 ++-- Doc/Manual/Warnings.html | 4 ++-- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index a4bb9e2d1..324be63ec 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -987,7 +987,7 @@ without setting the canthrow attribute you will get a warning message s
      -example.i:21: Warning(845): Unmanaged code contains a call to a SWIG_CSharpSetPendingException
      +example.i:21: Warning 845: Unmanaged code contains a call to a SWIG_CSharpSetPendingException
       method and C# code does not handle pending exceptions via the canthrow attribute.
       
      diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index fc5646c10..7ab997a11 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -1772,7 +1772,7 @@ If declarations such as these appear, you will get a warning message like this:
      -example.i:12: Warning(515): Overloaded method spam(unsigned short) ignored.
      +example.i:12: Warning 515: Overloaded method spam(unsigned short) ignored.
       Method spam(int) at example.i:11 used.
       
      diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index e66c1c7f3..cc7663cd4 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -684,7 +684,7 @@ void foo(Bar &b); If declarations such as these appear, you will get a warning message like this:

      -example.i:12: Warning(509): Overloaded spam(short) is shadowed by spam(int)
      +example.i:12: Warning 509: Overloaded spam(short) is shadowed by spam(int)
       at example.i:11.
       

      diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 1b628f802..406bdeaef 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -138,7 +138,7 @@ base class's methods. Typically you will get a warning when the module name is m

      -derived_module.i:8: Warning(401): Base class 'base' ignored - unknown module name for base. Either import 
      +derived_module.i:8: Warning 401: Base class 'base' ignored - unknown module name for base. Either import 
       the appropriate module interface file or specify the name of the module in the %import directive.
       
      diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index efa500c2d..7ed0da658 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -1710,7 +1710,7 @@ If declarations such as these appear, you will get a warning message like this:
      -example.i:12: Warning(509): Overloaded spam(short) is shadowed by spam(int)
      +example.i:12: Warning 509: Overloaded spam(short) is shadowed by spam(int)
       at example.i:11.
       
      diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 643a6daec..05457a906 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -1559,7 +1559,7 @@ you'll see a warning message like:

      -
      example.i:5: Warning(802): Warning for Derived: Base Base2 ignored.
      Multiple inheritance is not supported in Ruby.
      +
      example.i:5: Warning 802: Warning for Derived: Base Base2 ignored.
      Multiple inheritance is not supported in Ruby.
      @@ -1810,7 +1810,7 @@ message like this:

      -
      example.i:12: Warning(509): Overloaded spam(short) is shadowed by spam(int)
      at example.i:11.
      +
      example.i:12: Warning 509: Overloaded spam(short) is shadowed by spam(int)
      at example.i:11.
      diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 8e051a0ec..1194a4c26 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -1616,7 +1616,7 @@ warning message like this:
      -example.i:18: Warning(401): Nothing known about base class 'Foo'. Ignored.
      +example.i:18: Warning 401: Nothing known about base class 'Foo'. Ignored.
       
      @@ -2031,7 +2031,7 @@ Therefore, when SWIG encounters this situation, it may generate a warning messag
      -example.i:4: Warning(509): Overloaded foo(long) is shadowed by foo(int) at example.i:3.
      +example.i:4: Warning 509: Overloaded foo(long) is shadowed by foo(int) at example.i:3.
       
      @@ -2041,7 +2041,7 @@ or for statically typed languages like Java:
      -example.i:4: Warning(516): Overloaded method foo(long) ignored. Method foo(int)
      +example.i:4: Warning 516: Overloaded method foo(long) ignored. Method foo(int)
       at example.i:3 used.
       
      @@ -2091,7 +2091,7 @@ When wrapping an overloaded function, there is a chance that you will get an err
      -example.i:3: Warning(467): Overloaded foo(int) not supported (no type checking
      +example.i:3: Warning 467: Overloaded foo(int) not supported (no type checking
       rule for 'int').
       
      diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index 8b8c74dc0..11d4b7010 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -1502,7 +1502,7 @@ If declarations such as these appear, you will get a warning message like this:
      -example.i:12: Warning(509): Overloaded spam(short) is shadowed by spam(int)
      +example.i:12: Warning 509: Overloaded spam(short) is shadowed by spam(int)
       at example.i:11.
       
      diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index cd4c074f1..863d43f1f 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -3093,7 +3093,7 @@ SWIG can detect when the "optimal" attribute cannot be used and will ignore it a
      -example.i:28: Warning(474): Method XX::create() usage of the optimal attribute in the out 
      +example.i:28: Warning 474: Method XX::create() usage of the optimal attribute in the out 
       typemap at example.i:14 ignored as the following cannot be used to generate optimal code: 
       try {
         result = XX::create();
      @@ -3115,7 +3115,7 @@ In fact SWIG attempts to detect this and will issue a warning something like:
       
       
      -example.i:21: Warning(475): Multiple calls to XX::create() might be generated due to 
      +example.i:21: Warning 475: Multiple calls to XX::create() might be generated due to 
       optimal attribute usage in the out typemap at example.i:7.
       
      diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 15f3aa9d2..fd5d4916a 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -44,8 +44,8 @@ During compilation, SWIG may generate a variety of warning messages. For exampl
      -example.i:16: Warning(501): Overloaded declaration ignored.  bar(double)
      -example.i:15: Warning(501): Previous declaration is bar(int)
      +example.i:16: Warning 501: Overloaded declaration ignored.  bar(double)
      +example.i:15: Warning 501: Previous declaration is bar(int)
       
      From 5a3ba0d607132bfe78c5c23b3d8d2694a9250957 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 9 Jan 2010 17:20:11 +0000 Subject: [PATCH 304/352] Modify -debug-tags output to use standard file name/line reporting so that editors can easily navigate to the appropriate line git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11811 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 10 ++++++++++ Source/Swig/tree.c | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 2016a1e53..844092b38 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,16 @@ Version 1.3.41 (in progress) ============================ +2010-01-10: wsfulton + Modify -debug-tags output to use standard file name/line reporting so that editors + can easily navigate to the appropriate lines. + Was typically: + . top . include . include (/usr/share/swig/temp/trunk/Lib/swig.swg:312) + . top . include . include . include (/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39) + now: + /usr/share/swig/temp/trunk/Lib/swig.swg:312: . top . include . include + /usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39: . top . include . include . include + 2010-01-09: wsfulton Slight change to warning, error and diagnostic reporting. The warning number is no longer shown within brackets. This is to help default parsing of warning messages by diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c index 14d231afa..98ae9ed16 100644 --- a/Source/Swig/tree.c +++ b/Source/Swig/tree.c @@ -30,7 +30,7 @@ void Swig_print_tags(DOH *obj, DOH *root) { croot = root; while (obj) { - Printf(stdout, "%s . %s (%s:%d)\n", croot, nodeType(obj), Getfile(obj), Getline(obj)); + Swig_diagnostic(Getfile(obj), Getline(obj), "%s . %s\n", croot, nodeType(obj)); cobj = firstChild(obj); if (cobj) { newroot = NewStringf("%s . %s", croot, nodeType(obj)); @@ -268,7 +268,7 @@ void Swig_require(const char *ns, Node *n, ...) { } obj = Getattr(n, name); if (!opt && !obj) { - Printf(stderr, "%s:%d. Fatal error (Swig_require). Missing attribute '%s' in node '%s'.\n", Getfile(n), Getline(n), name, nodeType(n)); + Swig_error(Getfile(n), Getline(n), "Fatal error (Swig_require). Missing attribute '%s' in node '%s'.\n", name, nodeType(n)); assert(obj); } if (!obj) From a541f7c2030e5601bd717b68c6399234181fcd59 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 9 Jan 2010 19:26:34 +0000 Subject: [PATCH 305/352] Change -debug-template to use Swig_diagnostic for file/line display git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11812 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/cscanner.c | 4 ++-- Source/CParse/templ.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index b5c485f5d..a98bfb47f 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -135,7 +135,7 @@ static void scanner_locator(String *loc) { break; Putc(c, fn); } - /* Printf(stderr,"location: %s:%d\n",cparse_file,cparse_line); */ + /* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */ Scanner_set_location(scan,cparse_file,cparse_line); Delete(fn); } @@ -502,7 +502,7 @@ int yylex(void) { l = yylook(); - /* Printf(stdout, "%s:%d:::%d: '%s'\n", cparse_file, cparse_line, l, Scanner_text(scan)); */ + /* Swig_diagnostic(cparse_file, cparse_line, ":::%d: '%s'\n", l, Scanner_text(scan)); */ if (l == NONID) { last_id = 1; diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index c3cc115c6..91a1d31ff 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -512,7 +512,8 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) { if (template_debug) { tname = Copy(name); SwigType_add_template(tname, tparms); - Printf(stdout, "\n%s:%d: template_debug: Searching for match to: '%s'\n", cparse_file, cparse_line, tname); + Printf(stdout, "\n"); + Swig_diagnostic(cparse_file, cparse_line, "template_debug: Searching for match to: '%s'\n", tname); Delete(tname); tname = 0; } From e554146aacf1e0fe1b79aec35cc433d711cc8a85 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 9 Jan 2010 19:34:43 +0000 Subject: [PATCH 306/352] Fix a few inconsistencies in reporting of file/line numberings including modifying the overload warnings to now be two line warnings git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11813 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++ Doc/Manual/Lua.html | 4 +- Doc/Manual/Python.html | 4 +- Doc/Manual/Ruby.html | 6 ++- Doc/Manual/SWIGPlus.html | 6 ++- Doc/Manual/Tcl.html | 4 +- Doc/Manual/Warnings.html | 10 ++-- Source/Modules/allegrocl.cxx | 34 ++++++------- Source/Modules/lang.cxx | 2 +- Source/Modules/overload.cxx | 32 +++++++------ Source/Modules/r.cxx | 92 ++++++++++++++++++------------------ 11 files changed, 106 insertions(+), 92 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 844092b38..ebb8ae54e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2010-01-10: wsfulton + Fix a few inconsistencies in reporting of file/line numberings including modifying + the overload warnings 509, 512, 516 to now be two line warnings. + 2010-01-10: wsfulton Modify -debug-tags output to use standard file name/line reporting so that editors can easily navigate to the appropriate lines. diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index cc7663cd4..b236ab9f7 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -684,8 +684,8 @@ void foo(Bar &b); If declarations such as these appear, you will get a warning message like this:

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

      To fix this, you either need to ignore or rename one of the methods. For example: diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index 7ed0da658..b22a7e30e 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -1710,8 +1710,8 @@ If declarations such as these appear, you will get a warning message like this:

      -example.i:12: Warning 509: Overloaded spam(short) is shadowed by spam(int)
      -at example.i:11.
      +example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
      +example.i:11: Warning 509: as it is shadowed by spam(int).
       
      diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 05457a906..3b1e5c45c 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -1810,7 +1810,11 @@ message like this:

      -
      example.i:12: Warning 509: Overloaded spam(short) is shadowed by spam(int)
      at example.i:11.
      +
      +example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
      +example.i:11: Warning 509: as it is shadowed by spam(int).
      +
      +
      diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index 1194a4c26..bd8a7ab5d 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -2031,7 +2031,8 @@ Therefore, when SWIG encounters this situation, it may generate a warning messag
      -example.i:4: Warning 509: Overloaded foo(long) is shadowed by foo(int) at example.i:3.
      +example.i:4: Warning 509: Overloaded method foo(long) effectively ignored,
      +example.i:3: Warning 509: as it is shadowed by foo(int).
       
      @@ -2041,7 +2042,8 @@ or for statically typed languages like Java:
      -example.i:4: Warning 516: Overloaded method foo(long) ignored. Method foo(int)
      +example.i:4: Warning 516: Overloaded method foo(long) ignored,
      +example.i:3: Warning 516: using foo(int) instead.
       at example.i:3 used.
       
      diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index 11d4b7010..b37df2853 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -1502,8 +1502,8 @@ If declarations such as these appear, you will get a warning message like this:
      -example.i:12: Warning 509: Overloaded spam(short) is shadowed by spam(int)
      -at example.i:11.
      +example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
      +example.i:11: Warning 509: as it is shadowed by spam(int).
       
      diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index fd5d4916a..26707b1a0 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -494,22 +494,22 @@ example.i(4): Syntax error in input.
        -
      • 501. Overloaded declaration ignored. decl -
      • 502. Overloaded constructor ignored. decl +
      • 501. Overloaded declaration ignored. decl. Previous declaration is decl. +
      • 502. Overloaded constructor ignored. decl. Previous declaration is decl.
      • 503. Can't wrap 'identifier' unless renamed to a valid identifier.
      • 504. Function name must have a return type.
      • 505. Variable length arguments discarded.
      • 506. Can't wrap varargs with keyword arguments enabled.
      • 507. Adding native function name not supported (ignored).
      • 508. Declaration of 'name' shadows declaration accessible via operator->() at file:line. -
      • 509. Overloaded declaration is shadowed by declaration at file:line. +
      • 509. Overloaded method declaration effectively ignored, as it is shadowed by declaration.
      • 510. Friend function 'name' ignored.
      • 511. Can't use keyword arguments with overloaded functions. -
      • 512. Overloaded declaration const ignored. Non-const method at file:line used. +
      • 512. Overloaded method declaration ignored, using non-const method declaration instead.
      • 513. Can't generate wrappers for unnamed struct/class.
      • 514.
      • 515. -
      • 516. Overloaded method declaration ignored. Method declaration at file:line used. +
      • 516. Overloaded method declaration ignored, using declaration instead.
      • 517.
      • 518. Portability warning: File file1 will be overwritten by file2 on case insensitive filesystems such as Windows' FAT32 and NTFS unless the class/module name is renamed.
      • 519. %template() contains no name. Template method ignored: declaration diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 2f1b07296..bb5070a70 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1900,14 +1900,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n", - Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), + "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s(%s) ignored. Method %s(%s) const at %s:%d used.\n", - Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), - Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms), Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), + "using %s instead.\n", Swig_name_decl(nodes[i].n)); } } nodes[j].error = 1; @@ -1916,14 +1917,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n", - Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), + "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s(%s) const ignored. Method %s(%s) at %s:%d used.\n", - Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms), - Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms), Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), + "using %s instead.\n", Swig_name_decl(nodes[i].n)); } } nodes[j].error = 1; @@ -1937,15 +1939,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s is shadowed by %s at %s:%d.\n", - Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), - Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n), + "as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored. Method %s at %s:%d used.\n", - Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), - Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), + "using %s instead.\n", Swig_name_decl(nodes[i].n)); } nodes[j].error = 1; } diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index ea1f09133..3228a2cc1 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -175,7 +175,7 @@ int Dispatcher::emit_one(Node *n) { } else if (strcmp(tag, "types") == 0) { ret = typesDirective(n); } else { - Printf(stderr, "%s:%d. Unrecognized parse tree node type '%s'\n", input_file, line_number, tag); + Swig_error(input_file, line_number, "Unrecognized parse tree node type '%s'\n", tag); ret = SWIG_ERROR; } if (wrn) { diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 79656517a..14c677783 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -223,13 +223,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored. Non-const method %s at %s:%d used.\n", - Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), + "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored. Method %s at %s:%d used.\n", - Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), + "using %s instead.\n", Swig_name_decl(nodes[i].n)); } } nodes[j].error = 1; @@ -238,13 +240,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored. Non-const method %s at %s:%d used.\n", - Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), + "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored. Method %s at %s:%d used.\n", - Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), + "using %s instead.\n", Swig_name_decl(nodes[i].n)); } } nodes[j].error = 1; @@ -258,15 +262,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) { if (!nodes[j].error) { if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s is shadowed by %s at %s:%d.\n", - Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), - Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n), + "as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n)); } else { if (!Getattr(nodes[j].n, "overload:ignore")) Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored. Method %s at %s:%d used.\n", - Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), - Getfile(nodes[i].n), Getline(nodes[i].n)); + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), + "using %s instead.\n", Swig_name_decl(nodes[i].n)); } nodes[j].error = 1; } diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index fec2330bd..13b832752 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1486,8 +1486,8 @@ static List * Swig_overload_rank(Node *n, } if (!differ) { /* See if declarations differ by const only */ - String *d1 = Getattr(nodes[i].n,"decl"); - String *d2 = Getattr(nodes[j].n,"decl"); + String *d1 = Getattr(nodes[i].n, "decl"); + String *d2 = Getattr(nodes[j].n, "decl"); if (d1 && d2) { String *dq1 = Copy(d1); String *dq2 = Copy(d2); @@ -1497,49 +1497,47 @@ static List * Swig_overload_rank(Node *n, if (SwigType_isconst(d2)) { Delete(SwigType_pop(dq2)); } - if (Strcmp(dq1,dq2) == 0) { - + if (Strcmp(dq1, dq2) == 0) { + if (SwigType_isconst(d1) && !SwigType_isconst(d2)) { - if (script_lang_wrapping) { - // Swap nodes so that the const method gets ignored (shadowed by the non-const method) - Overloaded t = nodes[i]; - nodes[i] = nodes[j]; - nodes[j] = t; - } + if (script_lang_wrapping) { + // Swap nodes so that the const method gets ignored (shadowed by the non-const method) + Overloaded t = nodes[i]; + nodes[i] = nodes[j]; + nodes[j] = t; + } differ = 1; if (!nodes[j].error) { - if (script_lang_wrapping) { + if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n", - Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms), - Getfile(nodes[i].n), Getline(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s(%s) ignored. Method %s(%s) const at %s:%d used.\n", - Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms), - Getattr(nodes[i].n,"name"), ParmList_errorstr(nodes[i].parms), - Getfile(nodes[i].n), Getline(nodes[i].n)); - } + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), + "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); + } else { + if (!Getattr(nodes[j].n, "overload:ignore")) + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), + "using %s instead.\n", Swig_name_decl(nodes[i].n)); + } } nodes[j].error = 1; } else if (!SwigType_isconst(d1) && SwigType_isconst(d2)) { differ = 1; if (!nodes[j].error) { - if (script_lang_wrapping) { + if (script_lang_wrapping) { Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded %s(%s) const ignored. Non-const method at %s:%d used.\n", - Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms), - Getfile(nodes[i].n), Getline(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s(%s) const ignored. Method %s(%s) at %s:%d used.\n", - Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms), - Getattr(nodes[i].n,"name"), ParmList_errorstr(nodes[i].parms), - Getfile(nodes[i].n), Getline(nodes[i].n)); - } - } + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n), + "using non-const method %s instead.\n", Swig_name_decl(nodes[i].n)); + } else { + if (!Getattr(nodes[j].n, "overload:ignore")) + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), + "using %s instead.\n", Swig_name_decl(nodes[i].n)); + } + } nodes[j].error = 1; } } @@ -1549,18 +1547,18 @@ static List * Swig_overload_rank(Node *n, } if (!differ) { if (!nodes[j].error) { - if (script_lang_wrapping) { - Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s is shadowed by %s at %s:%d.\n", - Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), - Getfile(nodes[i].n), Getline(nodes[i].n)); - } else { - if (!Getattr(nodes[j].n, "overload:ignore")) - Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), - "Overloaded method %s ignored. Method %s at %s:%d used.\n", - Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n), - Getfile(nodes[i].n), Getline(nodes[i].n)); - } + if (script_lang_wrapping) { + Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s effectively ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n), + "as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n)); + } else { + if (!Getattr(nodes[j].n, "overload:ignore")) + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n), + "Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n)); + Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n), + "using %s instead.\n", Swig_name_decl(nodes[i].n)); + } nodes[j].error = 1; } } From 71c8881ddac38462cbdb8f40ba27ecf1c225abeb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 9 Jan 2010 20:00:27 +0000 Subject: [PATCH 307/352] Some more file and line numbering reporting consistency fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11814 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Typemaps.html | 8 ++++---- Doc/Manual/Warnings.html | 6 +++--- Source/Swig/typemap.c | 9 ++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 863d43f1f..7fe932828 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -3093,8 +3093,8 @@ SWIG can detect when the "optimal" attribute cannot be used and will ignore it a
        -example.i:28: Warning 474: Method XX::create() usage of the optimal attribute in the out 
        -typemap at example.i:14 ignored as the following cannot be used to generate optimal code: 
        +example.i:28: Warning 474: Method XX::create() usage of the optimal attribute ignored
        +example.i:14: Warning 474: in the out typemap as the following cannot be used to generate optimal code: 
         try {
           result = XX::create();
         } catch(const std::exception &e) {
        @@ -3115,8 +3115,8 @@ In fact SWIG attempts to detect this and will issue a warning something like:
         
         
        -example.i:21: Warning 475: Multiple calls to XX::create() might be generated due to 
        -optimal attribute usage in the out typemap at example.i:7.
        +example.i:21: Warning 475: Multiple calls to XX::create() might be generated due to optimal attribute usage in
        +example.i:7: Warning 475: the out typemap.
         
        diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 26707b1a0..cd65d2cee 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -484,8 +484,8 @@ example.i(4): Syntax error in input.
      • 469. No or improper directorin typemap defined for type
      • 470. Thread/reentrant unsafe wrapping, consider returning by value instead.
      • 471. Unable to use return type type in director method -
      • 474. Method method usage of the optimal attribute in the out typemap at file:line ignored as the following cannot be used to generate optimal code: code -
      • 475. Multiple calls to method might be generated due to optimal attribute usage in the out typemap at file:line. +
      • 474. Method method usage of the optimal attribute ignored in the out typemap as the following cannot be used to generate optimal code: code +
      • 475. Multiple calls to method might be generated due to optimal attribute usage in the out typemap.
      @@ -501,7 +501,7 @@ example.i(4): Syntax error in input.
    107. 505. Variable length arguments discarded.
    108. 506. Can't wrap varargs with keyword arguments enabled.
    109. 507. Adding native function name not supported (ignored). -
    110. 508. Declaration of 'name' shadows declaration accessible via operator->() at file:line. +
    111. 508. Declaration of 'name' shadows declaration accessible via operator->(), previous declaration of'declaration'.
    112. 509. Overloaded method declaration effectively ignored, as it is shadowed by declaration.
    113. 510. Friend function 'name' ignored.
    114. 511. Can't use keyword arguments with overloaded functions. diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index f0bf9eef3..ec44cd015 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1431,7 +1431,8 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No } } if (!optimal_substitution) { - Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(node), Getline(node), "Method %s usage of the optimal attribute in the out typemap at %s:%d ignored as the following cannot be used to generate optimal code: %s\n", Swig_name_decl(node), Getfile(s), Getline(s), clname); + Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(node), Getline(node), "Method %s usage of the optimal attribute ignored\n", Swig_name_decl(node)); + Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_IGNORED, Getfile(s), Getline(s), "in the out typemap as the following cannot be used to generate optimal code: %s\n", clname); Delattr(node, "tmap:out:optimal"); } } else { @@ -1465,8 +1466,10 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No } else { num_substitutions = typemap_replace_vars(s, locals, type, type, pname, (char *) lname, 1); } - if (optimal_substitution && num_substitutions > 1) - Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to optimal attribute usage in the out typemap at %s:%d.\n", Swig_name_decl(node), Getfile(s), Getline(s)); + if (optimal_substitution && num_substitutions > 1) { + Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to optimal attribute usage in\n", Swig_name_decl(node)); + Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "the out typemap.\n"); + } if (locals && f) { typemap_locals(s, locals, f, -1); From c1a302cbf2f37cd84d8ac0e24c15149ac0516b97 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 9 Jan 2010 20:01:16 +0000 Subject: [PATCH 308/352] Some more file and line numbering reporting consistency fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11815 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index ebb8ae54e..d22ea4e7b 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -3,7 +3,7 @@ Version 1.3.41 (in progress) 2010-01-10: wsfulton Fix a few inconsistencies in reporting of file/line numberings including modifying - the overload warnings 509, 512, 516 to now be two line warnings. + the overload warnings 509, 512, 516, 474, 475 to now be two line warnings. 2010-01-10: wsfulton Modify -debug-tags output to use standard file name/line reporting so that editors From 4a9d73e5327f599321522ec221904eebd2ca9482 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 9 Jan 2010 20:06:27 +0000 Subject: [PATCH 309/352] Warning text update git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11816 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Warnings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index cd65d2cee..c24a4364a 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -405,7 +405,7 @@ example.i(4): Syntax error in input.
    115. 315. Nothing known about 'identifier'.
    116. 316. Repeated %module directive.
    117. 317. Specialization of non-template 'name'. -
    118. 318. Instantiation of template name is ambiguous. Using templ at file:line +
    119. 318. Instantiation of template 'name' is ambiguous, instantiation templ used, instantiation templ ignored.
    120. 319. No access specifier given for base class name (ignored).
    121. 320. Explicit template instantiation ignored.
    122. 321. identifier conflicts with a built-in name. From 237f64a6e13ee31362f2a341cbaec48befcb7cc4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Jan 2010 22:37:28 +0000 Subject: [PATCH 310/352] subtle fix to -Fmicrosoft format adding in missing space git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11818 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 27 +++++++++++++++------------ Source/Swig/error.c | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index d22ea4e7b..f435f9cb8 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,21 @@ Version 1.3.41 (in progress) ============================ +2010-01-11: wsfulton + Slight change to warning, error and diagnostic reporting. The warning number is no + longer shown within brackets. This is to help default parsing of warning messages by + other tools, vim on Unix in particular. + + Example original display using -Fstandard: + example.i:20: Warning(401): Nothing known about base class 'B'. Ignored. + New display: + example.i:20: Warning 401: Nothing known about base class 'B'. Ignored. + + Also subtle fix to -Fmicrosoft format adding in missing space. Example original display: + example.i(20): Warning(401): Nothing known about base class 'Base'. Ignored. + New display: + example.i(20) : Warning 401: Nothing known about base class 'Base'. Ignored. + 2010-01-10: wsfulton Fix a few inconsistencies in reporting of file/line numberings including modifying the overload warnings 509, 512, 516, 474, 475 to now be two line warnings. @@ -15,18 +30,6 @@ Version 1.3.41 (in progress) /usr/share/swig/temp/trunk/Lib/swig.swg:312: . top . include . include /usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39: . top . include . include . include -2010-01-09: wsfulton - Slight change to warning, error and diagnostic reporting. The warning number is no - longer shown within brackets. This is to help default parsing of warning messages by - other tools, vim on Unix in particular. - - Example original display using -Fstandard: - example.i:20: Warning(401): Nothing known about base class 'B'. Ignored. - New display: - example.i:20: Warning 401: Nothing known about base class 'B'. Ignored. - - *** POTENTIAL INCOMPATIBILITY *** - 2010-01-03: wsfulton Fix missing file/line numbers for typemap warnings and in output from the -debug-tmsearch/-debug-tmused options. diff --git a/Source/Swig/error.c b/Source/Swig/error.c index 48a54f1d3..24e15e933 100644 --- a/Source/Swig/error.c +++ b/Source/Swig/error.c @@ -247,7 +247,7 @@ void Swig_error_msg_format(ErrorMessageFormat format) { by now a switch is used to translated into one. */ switch (format) { case EMF_MICROSOFT: - fmt_line = "%s(%d)"; + fmt_line = "%s(%d) "; fmt_eof = "%s(999999)"; /* Is there a special character for EOF? Just use a large number. */ break; case EMF_STANDARD: From 70d2bb62afe1bd8a6d304814a78489413b208e16 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Jan 2010 22:41:10 +0000 Subject: [PATCH 311/352] subtle fix to -Fmicrosoft format adding in missing space git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11819 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Warnings.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index c24a4364a..5409248c9 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -344,7 +344,7 @@ These can be overridden using command line options, for example: $ swig -python -Fstandard example.i example.i:4: Syntax error in input. $ swig -python -Fmicrosoft example.i -example.i(4): Syntax error in input. +example.i(4) : Syntax error in input.
    123. 14.9 Warning number reference

      From 3b06d6e44277ec1f175f7a41053eab2371d9b664 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 10 Jan 2010 22:51:19 +0000 Subject: [PATCH 312/352] subtle fix to -Fmicrosoft format adding in missing space git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11820 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Swig/error.c b/Source/Swig/error.c index 24e15e933..3271f93fc 100644 --- a/Source/Swig/error.c +++ b/Source/Swig/error.c @@ -248,7 +248,7 @@ void Swig_error_msg_format(ErrorMessageFormat format) { switch (format) { case EMF_MICROSOFT: fmt_line = "%s(%d) "; - fmt_eof = "%s(999999)"; /* Is there a special character for EOF? Just use a large number. */ + fmt_eof = "%s(999999) "; /* Is there a special character for EOF? Just use a large number. */ break; case EMF_STANDARD: default: From b2fc62f21f653c2a8d802418c79f0752181b21b1 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Wed, 13 Jan 2010 11:53:18 +0000 Subject: [PATCH 313/352] [PHP] Add datetime to the list of PHP predefined classes (patch from David Fletcher in SF#2931042). git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11822 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/php/phpkw.swg | 1 + 2 files changed, 5 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index f435f9cb8..f6d973d8d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2010-01-13: olly + [PHP] Add datetime to the list of PHP predefined classes (patch + from David Fletcher in SF#2931042). + 2010-01-11: wsfulton Slight change to warning, error and diagnostic reporting. The warning number is no longer shown within brackets. This is to help default parsing of warning messages by diff --git a/Lib/php/phpkw.swg b/Lib/php/phpkw.swg index 5e60583cb..dab05ed39 100644 --- a/Lib/php/phpkw.swg +++ b/Lib/php/phpkw.swg @@ -454,6 +454,7 @@ PHPCN(sqlitedatabase); PHPCN(sqliteresult); PHPCN(sqliteunbuffered); PHPCN(sqliteexception); +PHPCN(datetime); /* Built-in PHP functions (incomplete). */ PHPFN(cos); From 0635616c72464936c83d8cd11ad772ba255bbdc8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 20 Jan 2010 19:58:28 +0000 Subject: [PATCH 314/352] remove some dead code using which should be using SwigType_typedef_resolve_all instead of SwigType_typedef_resolve git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11823 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/r.cxx | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 13b832752..4e816486a 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -66,40 +66,6 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) { */ } -#if 0 -static String * getRType(Node *n) { - SwigType *elType = Getattr(n, "type"); - SwigType *elDecl = Getattr(n, "decl"); - //XXX How can we tell if this is already done. - SwigType_push(elType, elDecl); - String *ans; - - String *rtype = Swig_typemap_lookup("rtype", n, "", 0); - String *i = getRTypeName(elType); - - if(Len(i) == 0) { - SwigType *td = SwigType_typedef_resolve(elType); - if(td) { - // Printf(stderr, "Resolving typedef %s -> %s\n", elType, td); - i = getRTypeName(td); - } - } - // Printf(stderr, " i = %s, rtype = %s (for %s)\n", - // i, rtype, elType); - if(rtype) { - ans = NewString(""); - Printf(ans, "%s", rtype); - Replaceall(ans, "$R_class", Char(i)); - // Printf(stderr, "Found r type in typemap for %s (for %s) => %s (%s) => %s\n", - // SwigType_str(elType, 0), Getattr(n, "name"), rtype, i, ans); - } else { - ans = i; - } - - return(ans); -} -#endif - /********************* Tries to get the name of the R class corresponding to the given type e.g. struct A * is ARef, struct A** is ARefRef. @@ -530,12 +496,7 @@ int R::getFunctionPointerNumArgs(Node *n, SwigType *tt) { n = Getattr(n, "type"); if (debugMode) Printf(stderr, "type: %s\n", n); -#if 0 - SwigType *tmp = SwigType_typedef_resolve(tt); - - n = SwigType_typedef_resolve(tt); -#endif - + ParmList *parms = Getattr(n, "parms"); if (debugMode) Printf(stderr, "parms = %p\n", parms); From a2262ab599368cddf9d6eca45417e8567a05c351 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 20 Jan 2010 20:00:37 +0000 Subject: [PATCH 315/352] Use SwigType_typedef_resolve_all instead of SwigType_typedef_resolve git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11824 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/allegrocl.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index bb5070a70..8925053ab 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -721,8 +721,8 @@ String *internal_compose_foreign_type(Node *n, SwigType *ty) { if (res) { Printf(ffiType, "%s", res); } else { - SwigType *resolved_type = SwigType_typedef_resolve(tok); - if (resolved_type) { + SwigType *resolved_type = SwigType_typedef_resolve_all(tok); + if (Cmp(resolved_type, tok) != 0) { res = get_ffi_type(n, resolved_type, ""); if (res) { } else { From cc53e6c69eb122bc2b143112e27bdd832c75a9dd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 20 Jan 2010 20:01:13 +0000 Subject: [PATCH 316/352] minor formatting fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11825 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Java.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 7ab997a11..7869c5269 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -676,7 +676,9 @@ This is often combined with the -outdir to specify a package directory swig -java -package com.bloggs.swig -outdir com/bloggs/swig example.i
      +

      SWIG won't create the directory, so make sure it exists beforehand. +

      21.3.2 Functions

      From f112e4bac1639d162b08dff3abd6d282742407f9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 22 Jan 2010 20:39:54 +0000 Subject: [PATCH 317/352] Fix #2933129 - typemaps not being found when the unary scope operator (::) is used to denote global scope git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11827 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 22 ++- Examples/test-suite/common.mk | 2 + Examples/test-suite/global_namespace.i | 8 +- Examples/test-suite/typemap_global_scope.i | 215 +++++++++++++++++++++ Source/Modules/lang.cxx | 2 +- Source/Swig/misc.c | 6 +- Source/Swig/stype.c | 19 ++ Source/Swig/swig.h | 1 + Source/Swig/typemap.c | 34 ++-- Source/Swig/typesys.c | 11 +- 10 files changed, 290 insertions(+), 30 deletions(-) create mode 100644 Examples/test-suite/typemap_global_scope.i diff --git a/CHANGES.current b/CHANGES.current index f6d973d8d..398022036 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,26 @@ Version 1.3.41 (in progress) ============================ +2010-01-22: wsfulton + Fix #2933129 - typemaps not being found when the unary scope operator (::) is used to denote + global scope, the typemap is now used in situations like this: + + struct X {}; + %typemap(in) const X & "..." + void m(const ::X &); + + and this: + + struct X {}; + %typemap(in) const ::X & "..." + void m(const X &); + +2010-01-20: wsfulton + Fix some unary scope operator (::) denoting global scope problems in the types generated + into the C++ layer. Previously the unary scope operator was dropped in the generated code + if the type had any sort of qualifier, for example when using pointers, references, like + ::foo*, ::foo&, bar< ::foo* >. + 2010-01-13: olly [PHP] Add datetime to the list of PHP predefined classes (patch from David Fletcher in SF#2931042). @@ -217,7 +237,7 @@ Version 1.3.41 (in progress) -debug-csymbols - Display C symbols in the symbol tables 2009-11-03: wsfulton - Fix some usage of global scope operator, for example: + Fix some usage of unary scope operator (::) denoting global scope, for example: namespace AA { /* ... */ } using namespace ::AA; diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 203ea3e72..9830d6e7f 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -198,6 +198,7 @@ CPP_TEST_CASES += \ fvirtual \ global_namespace \ global_ns_arg \ + global_scope_types \ global_vars \ grouping \ ignore_parameter \ @@ -381,6 +382,7 @@ CPP_TEST_CASES += \ typedef_scope \ typedef_sizet \ typedef_struct \ + typemap_global_scope \ typemap_namespace \ typemap_ns_using \ typemap_numinputs \ diff --git a/Examples/test-suite/global_namespace.i b/Examples/test-suite/global_namespace.i index 02139f6c4..31dbb9e59 100644 --- a/Examples/test-suite/global_namespace.i +++ b/Examples/test-suite/global_namespace.i @@ -11,8 +11,8 @@ 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*& pr) {} - static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*& pr) {} + static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, ::Klass7*& pr) {} + static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*& pr) {} }; %} @@ -28,8 +28,8 @@ 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*& 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*& pr) {} + 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*& 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*& pr) {} }; %} diff --git a/Examples/test-suite/typemap_global_scope.i b/Examples/test-suite/typemap_global_scope.i new file mode 100644 index 000000000..92170363f --- /dev/null +++ b/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 "/*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 > "/* in typemap for $type */" +%typemap(in) const TemplateTest1< XX > &, const ::TemplateTest2< XX > &, const Space::TemplateTest3< XX > &, const ::Space::TemplateTest4< XX > & "/* in typemap for $type */" +%inline %{ +template struct TemplateTest1 { T m_t; }; +template struct TemplateTest2 { T m_t; }; +namespace Space { + template struct TemplateTest3 { T m_t; }; + template struct TemplateTest4 { T m_t; }; +} +%} + +%template(TemplateTest1XX) TemplateTest1< ::XX >; +%template(TemplateTest2XX) TemplateTest2< ::XX >; +%template(TemplateTest3XX) Space::TemplateTest3< ::XX >; +%template(TemplateTest4XX) Space::TemplateTest4< ::XX >; + +%inline %{ +void test_template_1a(TemplateTest1< ::XX > t, const TemplateTest1< ::XX > &tt) {} +void test_template_1b(::TemplateTest1< ::XX > t, const ::TemplateTest1< ::XX > &tt) {} + +void test_template_2a(TemplateTest2< ::XX > t, const TemplateTest2< ::XX > &tt) {} +void test_template_2b(::TemplateTest2< ::XX > t, const ::TemplateTest2< ::XX > &tt) {} + +void test_template_3a(Space::TemplateTest3< ::XX > t, const Space::TemplateTest3< ::XX > &tt) {} +void test_template_3b(::Space::TemplateTest3< ::XX > t, const ::Space::TemplateTest3< ::XX > &tt) {} +namespace Space { + void test_template_3c(Space::TemplateTest3< ::XX > t, const Space::TemplateTest3< ::XX > &tt) {} + void test_template_3d(::Space::TemplateTest3< ::XX > t, const ::Space::TemplateTest3< ::XX > &tt) {} + void test_template_3e(TemplateTest3< ::XX > t, const TemplateTest3< ::XX > &tt) {} +} + +void test_template_4a(Space::TemplateTest4< ::XX > t, const Space::TemplateTest4< ::XX > &tt) {} +void test_template_4b(::Space::TemplateTest4< ::XX > t, const ::Space::TemplateTest4< ::XX > &tt) {} +namespace Space { + void test_template_4c(Space::TemplateTest4< ::XX > t, const Space::TemplateTest4< ::XX > &tt) {} + void test_template_4d(::Space::TemplateTest4< ::XX > t, const ::Space::TemplateTest4< ::XX > &tt) {} + void test_template_4e(TemplateTest4< ::XX > t, const TemplateTest4< ::XX > &tt) {} +} +%} + +///////////////////////////////////////////////////////////////////// +// Enums +///////////////////////////////////////////////////////////////////// + +%typemap(in) Enum1, ::Enum2, Space::Enum3, ::Space::Enum4 "/*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/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 3228a2cc1..d381e20b9 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -782,7 +782,7 @@ int Language::typemapcopyDirective(Node *n) { Swig_error(input_file, line_number, "Can't copy typemap. Number of types differ.\n"); } else { if (Swig_typemap_copy(method, pattern, npattern) < 0) { - Swig_error(input_file, line_number, "Can't copy typemap.\n"); + Swig_error(input_file, line_number, "Can't copy typemap (%s) %s = %s\n", method, ParmList_str(pattern), ParmList_str(npattern)); } } items = nextSibling(items); diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 9b3e54fae..3a42ab682 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -893,7 +893,11 @@ String *Swig_scopename_suffix(const String *s) { /* ----------------------------------------------------------------------------- * Swig_scopename_check() * - * Checks to see if a name is qualified with a scope name + * Checks to see if a name is qualified with a scope name, examples: + * foo -> 0 + * ::foo -> 1 + * foo::bar -> 1 + * foo< ::bar > -> 0 * ----------------------------------------------------------------------------- */ int Swig_scopename_check(const String *s) { diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 707232558..17247b051 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -1094,6 +1094,25 @@ void SwigType_typename_replace(SwigType *t, String *pat, String *rep) { Delete(elem); } +/* ----------------------------------------------------------------------------- + * SwigType_remove_global_scope_prefix() + * + * Removes the unary scope operator (::) prefix indicating global scope in all + * components of the type + * ----------------------------------------------------------------------------- */ + +SwigType *SwigType_remove_global_scope_prefix(const SwigType *t) { + SwigType *result; + const char *type = Char(t); + if (strncmp(type, "::", 2) == 0) + type += 2; + result = NewString(type); + Replaceall(result, ".::", "."); + Replaceall(result, "(::", "("); + Replaceall(result, "enum ::", "enum "); + return result; +} + /* ----------------------------------------------------------------------------- * SwigType_check_decl() * diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 3e7ae8c38..e2dd71314 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -166,6 +166,7 @@ extern "C" { extern SwigType *SwigType_array_type(SwigType *t); extern String *SwigType_default(SwigType *t); extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep); + extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t); extern SwigType *SwigType_alttype(SwigType *t, int ltmap); extern void SwigType_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index ec44cd015..42ee042d4 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -62,47 +62,53 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper static Hash *typemaps[MAX_SCOPE]; static int tm_scope = 0; -static Hash *get_typemap(int tm_scope, SwigType *type) { +static Hash *get_typemap(int tm_scope, const SwigType *type) { Hash *tm = 0; SwigType *dtype = 0; + SwigType *hashtype; + if (SwigType_istemplate(type)) { String *ty = Swig_symbol_template_deftype(type, 0); dtype = Swig_symbol_type_qualify(ty, 0); - /* Printf(stderr,"gettm %s %s\n", type, dtype); */ type = dtype; Delete(ty); } - tm = Getattr(typemaps[tm_scope], type); + /* remove unary scope operator (::) prefix indicating global scope for looking up in the hashmap */ + hashtype = SwigType_remove_global_scope_prefix(type); + tm = Getattr(typemaps[tm_scope], hashtype); if (dtype) { if (!tm) { - String *t_name = SwigType_templateprefix(type); - if (!Equal(t_name, type)) { + String *t_name = SwigType_templateprefix(hashtype); + if (!Equal(t_name, hashtype)) { tm = Getattr(typemaps[tm_scope], t_name); } Delete(t_name); } Delete(dtype); } + Delete(hashtype); return tm; } -static void set_typemap(int tm_scope, SwigType *type, Hash *tm) { - SwigType *dtype = 0; +static void set_typemap(int tm_scope, const SwigType *type, Hash *tm) { + SwigType *hashtype = 0; if (SwigType_istemplate(type)) { String *ty = Swig_symbol_template_deftype(type, 0); - dtype = Swig_symbol_type_qualify(ty, 0); - /* Printf(stderr,"settm %s %s\n", type, dtype); */ - type = dtype; + String *tyq = Swig_symbol_type_qualify(ty, 0); + hashtype = SwigType_remove_global_scope_prefix(tyq); + Delete(tyq); Delete(ty); } else { - dtype = Copy(type); - type = dtype; + hashtype = SwigType_remove_global_scope_prefix(type); } - Setattr(typemaps[tm_scope], type, tm); - Delete(dtype); + + /* note that the unary scope operator (::) prefix indicating global scope has been removed for storing in the hashmap */ + Setattr(typemaps[tm_scope], hashtype, tm); + + Delete(hashtype); } diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 2022daf6a..9c06c979c 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -840,7 +840,8 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) { * * Given a type declaration, this function tries to fully qualify it according to * typedef scope rules. - * Inconsistency to be fixed: ::Foo returns ::Foo, whereas ::Foo * returns Foo * + * If the unary scope operator (::) is used as a prefix to the type to denote global + * scope, it is left in place. * ----------------------------------------------------------------------------- */ SwigType *SwigType_typedef_qualified(SwigType *t) { @@ -848,10 +849,6 @@ SwigType *SwigType_typedef_qualified(SwigType *t) { String *result; int i, len; - if (strncmp(Char(t), "::", 2) == 0) { - return Copy(t); - } - if (!typedef_qualified_cache) typedef_qualified_cache = NewHash(); result = Getattr(typedef_qualified_cache, t); @@ -999,10 +996,6 @@ SwigType *SwigType_typedef_qualified(SwigType *t) { Delete(qprefix); Delete(parms); } - if (strncmp(Char(e), "::", 2) == 0) { - Delitem(e, 0); - Delitem(e, 0); - } Append(result, e); Delete(ty); } else if (SwigType_isfunction(e)) { From 1de9c8b27f61b382dd843aa2f8d9b21ae6a2ceff Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 23 Jan 2010 15:30:42 +0000 Subject: [PATCH 318/352] Add a few comments about the smart pointer implementation git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11828 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/csharp/boost_shared_ptr.i | 3 +++ Lib/java/boost_intrusive_ptr.i | 5 ++++- Lib/java/boost_shared_ptr.i | 5 ++++- Lib/octave/boost_shared_ptr.i | 7 ++++++- Lib/python/boost_shared_ptr.i | 7 ++++++- Lib/shared_ptr.i | 4 ++++ 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Lib/csharp/boost_shared_ptr.i b/Lib/csharp/boost_shared_ptr.i index 2cb687356..52ac510ce 100644 --- a/Lib/csharp/boost_shared_ptr.i +++ b/Lib/csharp/boost_shared_ptr.i @@ -1,7 +1,9 @@ %include +// Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...) +// %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; @@ -10,6 +12,7 @@ //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" +// Typemap customisations... // plain value %typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{ diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i index 48f6c317b..9b9e1755f 100644 --- a/Lib/java/boost_intrusive_ptr.i +++ b/Lib/java/boost_intrusive_ptr.i @@ -1,13 +1,16 @@ %include +// Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...) +// %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; -// destructor mods +// destructor wrapper customisation %feature("unref") TYPE "(void)arg1; delete smartarg1;" +// Typemap customisations... %typemap(in) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ // plain value diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i index 75762f84f..38262f20c 100644 --- a/Lib/java/boost_shared_ptr.i +++ b/Lib/java/boost_shared_ptr.i @@ -1,15 +1,18 @@ %include +// Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...) +// %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; -// destructor mods +// destructor wrapper customisation %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" +// Typemap customisations... // plain value %typemap(in) CONST TYPE ($&1_type argp = 0) %{ diff --git a/Lib/octave/boost_shared_ptr.i b/Lib/octave/boost_shared_ptr.i index 7ae4dda9f..2a3c1532f 100644 --- a/Lib/octave/boost_shared_ptr.i +++ b/Lib/octave/boost_shared_ptr.i @@ -1,17 +1,22 @@ %include +// Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...) +// %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; -// destructor mods +// destructor wrapper customisation %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" +// Feature to adapt the code generated in the swigregister functions for smart pointers %feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > } +// Typemap customisations... + // plain value %typemap(in) CONST TYPE (void *argp, int res = 0) { int newmem = 0; diff --git a/Lib/python/boost_shared_ptr.i b/Lib/python/boost_shared_ptr.i index b4c0b5b83..d5dffcda9 100644 --- a/Lib/python/boost_shared_ptr.i +++ b/Lib/python/boost_shared_ptr.i @@ -6,18 +6,23 @@ #define SHARED_PTR_DISOWN 0 #endif +// Language specific macro implementing all the customisations for handling the smart pointer %define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...) +// %naturalvar is as documented for member variables %naturalvar TYPE; %naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; -// destructor mods +// destructor wrapper customisation %feature("unref") TYPE //"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n" "(void)arg1; delete smartarg1;" +// Feature to adapt the code generated in the swigregister functions for smart pointers %feature("smartptr", noblock=1) TYPE { SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > } +// Typemap customisations... + // plain value %typemap(in) CONST TYPE (void *argp, int res = 0) { int newmem = 0; diff --git a/Lib/shared_ptr.i b/Lib/shared_ptr.i index 709791502..ffff2b40b 100644 --- a/Lib/shared_ptr.i +++ b/Lib/shared_ptr.i @@ -1,3 +1,7 @@ +// The main implementation detail in using this smart pointer of a type is to customise the code generated +// to use a pointer to the smart pointer of the type, rather than the usual pointer to the underlying type. +// So for some type T, shared_ptr * is used rather than T *. + // shared_ptr namespaces could be boost or std or std::tr1 // For example for std::tr1, use: // #define SWIG_SHARED_PTR_NAMESPACE std From 4b1d7aa73dc1af2d5c137e762d603bfaa11a11fe Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 23 Jan 2010 22:24:45 +0000 Subject: [PATCH 319/352] revert 11743 - accidental checkin git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11829 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/python/class/example.i | 8 ++++- Examples/python/class/runme.py | 55 ++++++++++++++++++++++++++++----- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/Examples/python/class/example.i b/Examples/python/class/example.i index aa28dde80..75700b305 100644 --- a/Examples/python/class/example.i +++ b/Examples/python/class/example.i @@ -1,4 +1,10 @@ /* File : example.i */ %module example -int printf(const char *fmt, ...); +%{ +#include "example.h" +%} + +/* Let's just grab the original header file here */ +%include "example.h" + diff --git a/Examples/python/class/runme.py b/Examples/python/class/runme.py index 54543be67..f1272ae81 100644 --- a/Examples/python/class/runme.py +++ b/Examples/python/class/runme.py @@ -1,10 +1,51 @@ +# file: runme.py -from example import * +# This file illustrates the proxy class C++ interface generated +# by SWIG. -printf("hello\n") +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" -name = "%shoot" -num = 22 -printf("Hello %s. Your number is %d\n" % (name, num)) -print("hello there %s." % name); -printf("Your result is 90%.\n") From 83576031c32aff64b46536de21ebcd15e41ef4cf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 28 Jan 2010 07:22:42 +0000 Subject: [PATCH 320/352] Add another example for clarification in SwigType_templateprefix() git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11830 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/typeobj.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index cbc2fd414..abd84ee09 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -854,9 +854,8 @@ SwigType *SwigType_add_template(SwigType *t, ParmList *parms) { * Returns the prefix before the first template definition. * For example: * - * Foo<(p.int)>::bar - * - * returns "Foo" + * Foo<(p.int)>::bar => Foo + * r.q(const).Foo<(p.int)>::bar => r.q(const).Foo * ----------------------------------------------------------------------------- */ String *SwigType_templateprefix(const SwigType *t) { From d02f543dbca40b4f48e18f8150e782c88ba8150b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 28 Jan 2010 07:25:59 +0000 Subject: [PATCH 321/352] Fix typemap matching bug when a templated type has a typemap both specialized and not specialized - the wrong typemap would sometimes be used git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11831 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 10 ++++++ Doc/Manual/Typemaps.html | 5 +++ Examples/test-suite/common.mk | 1 + Source/Swig/typemap.c | 57 ++++++++++++++++++++++++++++------- 4 files changed, 62 insertions(+), 11 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 398022036..b1070d3c7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,16 @@ Version 1.3.41 (in progress) ============================ +2010-01-28: wsfulton + Fix typemap matching bug when a templated type has a typemap both specialized and not + specialized. For example: + + template struct XX { ... }; + %typemap(in) const XX & "..." + %typemap(in) const XX< int > & "..." + + resulted in the 2nd typemap being applied for all T in XX< T >. + 2010-01-22: wsfulton Fix #2933129 - typemaps not being found when the unary scope operator (::) is used to denote global scope, the typemap is now used in situations like this: diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 7fe932828..d2db34432 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -1025,6 +1025,11 @@ checks are made:
    124. Typemaps that match the stripped TYPE only. +

      +If TYPE is a C++ template, the matching rules above are repeated with the template parameterization removed. +For example if TYPE is X< double > , then repeat with the type simply as X. +

      +

      If TYPE is an array. The following transformation is made:

      diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 9830d6e7f..0dfe73939 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -386,6 +386,7 @@ CPP_TEST_CASES += \ typemap_namespace \ typemap_ns_using \ typemap_numinputs \ + typemap_template \ typemap_out_optimal \ typemap_variables \ typemap_various \ diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 42ee042d4..b9d53d5d1 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -78,16 +78,7 @@ static Hash *get_typemap(int tm_scope, const SwigType *type) { hashtype = SwigType_remove_global_scope_prefix(type); tm = Getattr(typemaps[tm_scope], hashtype); - if (dtype) { - if (!tm) { - String *t_name = SwigType_templateprefix(hashtype); - if (!Equal(t_name, hashtype)) { - tm = Getattr(typemaps[tm_scope], t_name); - } - Delete(t_name); - } - Delete(dtype); - } + Delete(dtype); Delete(hashtype); return tm; @@ -105,7 +96,7 @@ static void set_typemap(int tm_scope, const SwigType *type, Hash *tm) { hashtype = SwigType_remove_global_scope_prefix(type); } - /* note that the unary scope operator (::) prefix indicating global scope has been removed for storing in the hashmap */ + /* note that the unary scope operator (::) prefix indicating global scope has been removed from the type */ Setattr(typemaps[tm_scope], hashtype, tm); Delete(hashtype); @@ -653,6 +644,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type SwigType *noarrays = 0; SwigType *primitive = 0; SwigType *ctype = 0; + SwigType *template_prefix = 0; int ts; int isarray; const String *cname = 0; @@ -710,6 +702,48 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type if (result) backup = result; } + + /* look for the type reduced to just the template prefix */ + Delete(template_prefix); + template_prefix = SwigType_templateprefix(ctype); + tm = get_typemap(ts, template_prefix); + if (template_prefix) { + if (debug_display && cqualifiedname) + Printf(stdout, " Looking for: %s\n", SwigType_str(template_prefix, cqualifiedname)); + if (tm && cqualifiedname) { + tm1 = Getattr(tm, cqualifiedname); + if (tm1) { + result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */ + if (result && Getattr(result, "code")) + goto ret_result; + if (result) + backup = result; + } + } + if (debug_display && cname) + Printf(stdout, " Looking for: %s\n", SwigType_str(template_prefix, cname)); + if (tm && cname) { + tm1 = Getattr(tm, cname); + if (tm1) { + result = Getattr(tm1, tm_method); /* See if there is a type - name match */ + if (result && Getattr(result, "code")) + goto ret_result; + if (result) + backup = result; + } + } + if (debug_display) + Printf(stdout, " Looking for: %s\n", SwigType_str(template_prefix, 0)); + if (tm) { + result = Getattr(tm, tm_method); /* See if there is simply a type match */ + if (result && Getattr(result, "code")) + goto ret_result; + if (result) + backup = result; + } + } + + /* look for [ANY] arrays */ isarray = SwigType_isarray(ctype); if (isarray) { /* If working with arrays, strip away all of the dimensions and replace with "ANY". @@ -828,6 +862,7 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type result = backup; ret_result: + Delete(template_prefix); Delete(noarrays); Delete(primitive); if ((unstripped) && (unstripped != type)) From 78d03a5220ec2d1b167d9293f89fc092916a31bf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 28 Jan 2010 22:39:44 +0000 Subject: [PATCH 322/352] Typemap matching rules update git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11832 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Typemaps.html | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index d2db34432..14623b37d 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -998,7 +998,8 @@ within a particular namespace. In this example, this is done using the class de

      -The section describes the pattern matching rules by which C datatypes are associated with typemaps. +The section describes the pattern matching rules by which C/C++ datatypes are associated with typemaps. +The matching rules can be observed in practice by using the debugging options also described.

      10.3.1 Basic matching rules

      @@ -1013,21 +1014,17 @@ is used.
      • Typemaps that exactly match TYPE and NAME.
      • Typemaps that exactly match TYPE only. +
      • If TYPE is a C++ template of type T< TPARMS >, where TPARMS are the template parameters, + the type is stripped of the template parameters and the following checks are then made: +
          +
        • Typemaps that exactly match T and NAME. +
        • Typemaps that exactly match T only. +

      -If TYPE includes qualifiers (const, volatile, etc.), they are stripped and the following -checks are made: -

      - -
        -
      • Typemaps that match the stripped TYPE and NAME. -
      • Typemaps that match the stripped TYPE only. -
      - -

      -If TYPE is a C++ template, the matching rules above are repeated with the template parameterization removed. -For example if TYPE is X< double > , then repeat with the type simply as X. +If TYPE includes qualifiers (const, volatile, etc.), they are stripped to form a new stripped type +and the matching rules above are repeated on the stripped type.

      From a4d28ba148b13ce25804cc8d1e326d8b1eb6ed34 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 29 Jan 2010 06:55:38 +0000 Subject: [PATCH 323/352] Remove unnecessary duplicate typemap lookup git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11833 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/swig.h | 1 + Source/Swig/typemap.c | 4 ++-- Source/Swig/typeobj.c | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index e2dd71314..6abe6f5c5 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -158,6 +158,7 @@ extern "C" { extern String *SwigType_namestr(const SwigType *t); extern String *SwigType_templateprefix(const SwigType *t); extern String *SwigType_templatesuffix(const SwigType *t); + extern String *SwigType_istemplate_templateprefix(const SwigType *t); extern String *SwigType_templateargs(const SwigType *t); extern String *SwigType_prefix(const SwigType *t); extern int SwigType_array_ndim(SwigType *t); diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index b9d53d5d1..7b1ea529b 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -705,9 +705,9 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type /* look for the type reduced to just the template prefix */ Delete(template_prefix); - template_prefix = SwigType_templateprefix(ctype); - tm = get_typemap(ts, template_prefix); + template_prefix = SwigType_istemplate_templateprefix(ctype); if (template_prefix) { + tm = get_typemap(ts, template_prefix); if (debug_display && cqualifiedname) Printf(stdout, " Looking for: %s\n", SwigType_str(template_prefix, cqualifiedname)); if (tm && cqualifiedname) { diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index abd84ee09..81a5aeff1 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -852,10 +852,12 @@ SwigType *SwigType_add_template(SwigType *t, ParmList *parms) { * SwigType_templateprefix() * * Returns the prefix before the first template definition. + * Returns the type unmodified if not a template. * For example: * * Foo<(p.int)>::bar => Foo * r.q(const).Foo<(p.int)>::bar => r.q(const).Foo + * Foo => Foo * ----------------------------------------------------------------------------- */ String *SwigType_templateprefix(const SwigType *t) { @@ -896,6 +898,25 @@ String *SwigType_templatesuffix(const SwigType *t) { return NewStringEmpty(); } +/* ----------------------------------------------------------------------------- + * SwigType_istemplate_templateprefix() + * + * Combines SwigType_istemplate and SwigType_templateprefix efficiently into one function. + * Returns the prefix before the first template definition. + * Returns NULL if not a template. + * For example: + * + * Foo<(p.int)>::bar => Foo + * r.q(const).Foo<(p.int)>::bar => r.q(const).Foo + * Foo => NULL + * ----------------------------------------------------------------------------- */ + +String *SwigType_istemplate_templateprefix(const SwigType *t) { + const char *s = Char(t); + const char *c = strstr(s, "<("); + return c ? NewStringWithSize(s, c - s) : 0; +} + /* ----------------------------------------------------------------------------- * SwigType_templateargs() * From 160ce6d4a8e515c5bd98a6d427478a02b8bc7d1c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 29 Jan 2010 18:49:16 +0000 Subject: [PATCH 324/352] Slight performance tweak for templates git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11834 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 22 ++++++++++++---------- Source/Modules/allegrocl.cxx | 27 +++++++++++++++++---------- Source/Swig/naming.c | 31 +++++++++---------------------- Source/Swig/typesys.c | 6 +++--- 4 files changed, 41 insertions(+), 45 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index dafecc96f..cc04f2be2 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -211,9 +211,9 @@ Hash *Swig_cparse_features(void) { } static String *feature_identifier_fix(String *s) { - if (SwigType_istemplate(s)) { - String *tp, *ts, *ta, *tq; - tp = SwigType_templateprefix(s); + String *tp = SwigType_istemplate_templateprefix(s); + if (tp) { + String *ts, *ta, *tq; ts = SwigType_templatesuffix(s); ta = SwigType_templateargs(s); tq = Swig_symbol_type_qualify(ta,0); @@ -756,14 +756,15 @@ static List *pure_abstract(Node *n) { static String *make_class_name(String *name) { String *nname = 0; + String *prefix; if (Namespaceprefix) { nname= NewStringf("%s::%s", Namespaceprefix, name); } else { nname = NewString(name); } - if (SwigType_istemplate(nname)) { - String *prefix, *args, *qargs; - prefix = SwigType_templateprefix(nname); + prefix = SwigType_istemplate_templateprefix(nname); + if (prefix) { + String *args, *qargs; args = SwigType_templateargs(nname); qargs = Swig_symbol_type_qualify(args,0); Append(prefix,qargs); @@ -3380,6 +3381,7 @@ cpp_declaration : cpp_class_decl { $$ = $1; } /* A simple class/struct/union definition */ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { if (nested_template == 0) { + String *prefix; List *bases = 0; Node *scope = 0; $$ = new_node("class"); @@ -3428,9 +3430,9 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { if ($4) { bases = make_inherit_list($3,Getattr($4,"public")); } - if (SwigType_istemplate($3)) { - String *fbase, *tbase, *prefix; - prefix = SwigType_templateprefix($3); + prefix = SwigType_istemplate_templateprefix($3); + if (prefix) { + String *fbase, *tbase; if (Namespaceprefix) { fbase = NewStringf("%s::%s", Namespaceprefix,$3); tbase = NewStringf("%s::%s", Namespaceprefix, prefix); @@ -3441,7 +3443,6 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { Swig_name_inherit(tbase,fbase); Delete(fbase); Delete(tbase); - Delete(prefix); } if (strcmp($2,"class") == 0) { cplus_mode = CPLUS_PRIVATE; @@ -3492,6 +3493,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { } } class_decl[class_level++] = $$; + Delete(prefix); inclass = 1; } } cpp_members RBRACE cpp_opt_declarators { diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 8925053ab..0b3fb0532 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -374,9 +374,12 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, // Swig_print_node(n); } - if (SwigType_istemplate(name)) { - String *temp = strip_namespaces(SwigType_templateprefix(name)); + String *tname = SwigType_istemplate_templateprefix(name); + if (tname) { + String *temp = strip_namespaces(tname); name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name)); + Delete(temp); + Delete(tname); } val = lookup_defined_foreign_type(k); @@ -1085,11 +1088,12 @@ void emit_stub_class(Node *n) { if (Getattr(n, "allegrocl:synonym:already-been-stubbed")) return; - if (SwigType_istemplate(name)) { - String *temp = strip_namespaces(SwigType_templateprefix(name)); + String *tname = SwigType_istemplate_templateprefix(name); + if (tname) { + String *temp = strip_namespaces(tname); name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name)); - Delete(temp); + Delete(tname); } else { name = strip_namespaces(name); } @@ -1276,11 +1280,12 @@ void emit_class(Node *n) { String *ns_list = listify_namespace(Getattr(n, "allegrocl:namespace")); String *name = Getattr(n, is_tempInst ? "real-name" : "name"); - if (SwigType_istemplate(name)) { - String *temp = strip_namespaces(SwigType_templateprefix(name)); + String *tname = SwigType_istemplate_templateprefix(name); + if (tname) { + String *temp = strip_namespaces(tname); name = NewStringf("%s%s%s", temp, SwigType_templateargs(name), SwigType_templatesuffix(name)); - Delete(temp); + Delete(tname); } else { name = strip_namespaces(name); } @@ -1335,10 +1340,12 @@ void emit_typedef(Node *n) { if (in_class) { String *class_name = Getattr(in_class, "name"); - if (SwigType_istemplate(class_name)) { - String *temp = strip_namespaces(SwigType_templateprefix(class_name)); + String *tname = SwigType_istemplate_templateprefix(class_name); + if (tname) { + String *temp = strip_namespaces(tname); class_name = NewStringf("%s%s%s", temp, SwigType_templateargs(class_name), SwigType_templatesuffix(class_name)); Delete(temp); + Delete(tname); } name = NewStringf("%s__%s", class_name, sym_name); diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index d69eb4225..9738bed66 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -474,25 +474,12 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType Delete(cls); } /* A template-based class lookup, check name first */ - if (!rn && SwigType_istemplate(name)) { - String *t_name = SwigType_templateprefix(name); - if (!Equal(t_name, name)) { + if (!rn) { + String *t_name = SwigType_istemplate_templateprefix(name); + if (t_name) rn = Swig_name_object_get(namehash, prefix, t_name, decl); - } Delete(t_name); } - /* A template-based class lookup */ - /* - if (!rn && SwigType_istemplate(prefix)) { - String *t_prefix = SwigType_templateprefix(prefix); - if (Strcmp(t_prefix, prefix) != 0) { - String *t_name = SwigType_templateprefix(name); - rn = Swig_name_object_get(namehash, t_prefix, t_name, decl); - Delete(t_name); - } - Delete(t_prefix); - } - */ } /* A wildcard-based class lookup */ if (!rn) { @@ -663,10 +650,9 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d if (name) { String *tname = NewStringEmpty(); /* add features for 'root' template */ - if (SwigType_istemplate(name)) { - String *dname = SwigType_templateprefix(name); + String *dname = SwigType_istemplate_templateprefix(name); + if (dname) { features_get(features, dname, decl, ncdecl, node); - Delete(dname); } /* Catch-all */ features_get(features, name, decl, ncdecl, node); @@ -684,16 +670,16 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d /* A specific class lookup */ if (Len(prefix)) { /* A template-based class lookup */ - if (SwigType_istemplate(prefix)) { - String *tprefix = SwigType_templateprefix(prefix); + String *tprefix = SwigType_istemplate_templateprefix(prefix); + if (tprefix) { Clear(tname); Printf(tname, "%s::%s", tprefix, name); features_get(features, tname, decl, ncdecl, node); - Delete(tprefix); } Clear(tname); Printf(tname, "%s::%s", prefix, name); features_get(features, tname, decl, ncdecl, node); + Delete(tprefix); } } else { /* Lookup in the global namespace only */ @@ -702,6 +688,7 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d features_get(features, tname, decl, ncdecl, node); } Delete(tname); + Delete(dname); } if (name && SwigType_istemplate(name)) { /* add features for complete template type */ diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 9c06c979c..88fdfc3fd 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -1161,9 +1161,9 @@ int SwigType_isclass(SwigType *t) { isclass = 1; } /* Hmmm. Not a class. If a template, it might be uninstantiated */ - if (!isclass && SwigType_istemplate(qtys)) { - String *tp = SwigType_templateprefix(qtys); - if (Strcmp(tp, t) != 0) { + if (!isclass) { + String *tp = SwigType_istemplate_templateprefix(qtys); + if (tp && Strcmp(tp, t) != 0) { isclass = SwigType_isclass(tp); } Delete(tp); From 590567d57fdc1a26590e1ae50bbcfe55d3cf8afe Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 1 Feb 2010 20:23:34 +0000 Subject: [PATCH 325/352] Factor out the common code within typemap_search() into typemap_search_helper() git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11838 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Swig/typemap.c | 211 ++++++++++++++---------------------------- 1 file changed, 72 insertions(+), 139 deletions(-) diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 7b1ea529b..93f7c4db7 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -630,6 +630,56 @@ static void debug_search_result_display(Node *tm) { Printf(stdout, " None found\n"); } +/* ----------------------------------------------------------------------------- + * typemap_search_helper() + * + * Helper function for typemap_search to see if there is a type match in the typemap + * tm. A match is sought in this order: + * %typemap(tm_method) ctype cqualifiedname + * %typemap(tm_method) ctype cname + * %typemap(tm_method) ctype + * ----------------------------------------------------------------------------- */ + +static Hash *typemap_search_helper(int debug_display, Hash *tm, const String *tm_method, SwigType *ctype, const String *cqualifiedname, const String *cname, Hash **backup) { + Hash *result = 0; + Hash *tm1; + if (debug_display && cqualifiedname) + Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cqualifiedname)); + if (tm && cqualifiedname) { + tm1 = Getattr(tm, cqualifiedname); + if (tm1) { + result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */ + if (result && Getattr(result, "code")) + goto ret_result; + if (result) + *backup = result; + } + } + if (debug_display && cname) + Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cname)); + if (tm && cname) { + tm1 = Getattr(tm, cname); + if (tm1) { + result = Getattr(tm1, tm_method); /* See if there is a type - name match */ + if (result && Getattr(result, "code")) + goto ret_result; + if (result) + *backup = result; + } + } + if (debug_display) + Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, 0)); + if (tm) { + result = Getattr(tm, tm_method); /* See if there is simply a type match */ + if (result && Getattr(result, "code")) + goto ret_result; + if (result) + *backup = result; + } +ret_result: + return result; +} + /* ----------------------------------------------------------------------------- * typemap_search() * @@ -639,12 +689,11 @@ static void debug_search_result_display(Node *tm) { * ----------------------------------------------------------------------------- */ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type, const_String_or_char_ptr name, const_String_or_char_ptr qualifiedname, SwigType **matchtype, Node *node) { - Hash *result = 0, *tm, *tm1, *tma; + Hash *result = 0; + Hash *tm; Hash *backup = 0; - SwigType *noarrays = 0; SwigType *primitive = 0; SwigType *ctype = 0; - SwigType *template_prefix = 0; int ts; int isarray; const String *cname = 0; @@ -669,77 +718,19 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type while (ctype) { /* Try to get an exact type-match */ tm = get_typemap(ts, ctype); - if (debug_display && cqualifiedname) - Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cqualifiedname)); - if (tm && cqualifiedname) { - tm1 = Getattr(tm, cqualifiedname); - if (tm1) { - result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */ - if (result && Getattr(result, "code")) - goto ret_result; - if (result) - backup = result; - } - } - if (debug_display && cname) - Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, cname)); - if (tm && cname) { - tm1 = Getattr(tm, cname); - if (tm1) { - result = Getattr(tm1, tm_method); /* See if there is a type - name match */ - if (result && Getattr(result, "code")) - goto ret_result; - if (result) - backup = result; - } - } - if (debug_display) - Printf(stdout, " Looking for: %s\n", SwigType_str(ctype, 0)); - if (tm) { - result = Getattr(tm, tm_method); /* See if there is simply a type match */ - if (result && Getattr(result, "code")) - goto ret_result; - if (result) - backup = result; - } + result = typemap_search_helper(debug_display, tm, tm_method, ctype, cqualifiedname, cname, &backup); + if (result) + goto ret_result; - /* look for the type reduced to just the template prefix */ - Delete(template_prefix); - template_prefix = SwigType_istemplate_templateprefix(ctype); - if (template_prefix) { - tm = get_typemap(ts, template_prefix); - if (debug_display && cqualifiedname) - Printf(stdout, " Looking for: %s\n", SwigType_str(template_prefix, cqualifiedname)); - if (tm && cqualifiedname) { - tm1 = Getattr(tm, cqualifiedname); - if (tm1) { - result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */ - if (result && Getattr(result, "code")) - goto ret_result; - if (result) - backup = result; - } - } - if (debug_display && cname) - Printf(stdout, " Looking for: %s\n", SwigType_str(template_prefix, cname)); - if (tm && cname) { - tm1 = Getattr(tm, cname); - if (tm1) { - result = Getattr(tm1, tm_method); /* See if there is a type - name match */ - if (result && Getattr(result, "code")) - goto ret_result; - if (result) - backup = result; - } - } - if (debug_display) - Printf(stdout, " Looking for: %s\n", SwigType_str(template_prefix, 0)); - if (tm) { - result = Getattr(tm, tm_method); /* See if there is simply a type match */ - if (result && Getattr(result, "code")) - goto ret_result; + { + /* Look for the type reduced to just the template prefix */ + SwigType *template_prefix = SwigType_istemplate_templateprefix(ctype); + if (template_prefix) { + tm = get_typemap(ts, template_prefix); + result = typemap_search_helper(debug_display, tm, tm_method, template_prefix, cqualifiedname, cname, &backup); + Delete(template_prefix); if (result) - backup = result; + goto ret_result; } } @@ -748,45 +739,12 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type if (isarray) { /* If working with arrays, strip away all of the dimensions and replace with "ANY". See if that generates a match */ - if (!noarrays) { - noarrays = strip_arrays(ctype); - } - tma = get_typemap(ts, noarrays); - if (debug_display && cqualifiedname) - Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, cqualifiedname)); - if (tma && cqualifiedname) { - tm1 = Getattr(tma, cqualifiedname); - if (tm1) { - result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */ - if (result && Getattr(result, "code")) - goto ret_result; - if (result) - backup = result; - } - } - if (debug_display && cname) - Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, cname)); - if (tma && cname) { - tm1 = Getattr(tma, cname); - if (tm1) { - result = Getattr(tm1, tm_method); /* See if there is a type - name match */ - if (result && Getattr(result, "code")) - goto ret_result; - if (result) - backup = result; - } - } - if (debug_display) - Printf(stdout, " Looking for: %s\n", SwigType_str(noarrays, 0)); - if (tma) { - result = Getattr(tma, tm_method); /* See if there is a type match */ - if (result && Getattr(result, "code")) - goto ret_result; - if (result) - backup = result; - } + SwigType *noarrays = strip_arrays(ctype); + tm = get_typemap(ts, noarrays); + result = typemap_search_helper(debug_display, tm, tm_method, noarrays, cqualifiedname, cname, &backup); Delete(noarrays); - noarrays = 0; + if (result) + goto ret_result; } /* No match so far. If the type is unstripped, we'll strip its @@ -820,33 +778,10 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type primitive = SwigType_default(type); while (primitive) { tm = get_typemap(ts, primitive); - if (debug_display && cqualifiedname) - Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, cqualifiedname)); - if (tm && cqualifiedname) { - tm1 = Getattr(tm, cqualifiedname); - if (tm1) { - result = Getattr(tm1, tm_method); /* See if there is a type - qualified name match */ - if (result) - goto ret_result; - } - } - if (debug_display && cname) - Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, cname)); - if (tm && cname) { - tm1 = Getattr(tm, cname); - if (tm1) { - result = Getattr(tm1, tm_method); /* See if there is a type - name match */ - if (result) - goto ret_result; - } - } - if (debug_display) - Printf(stdout, " Looking for: %s\n", SwigType_str(primitive, 0)); - if (tm) { - result = Getattr(tm, tm_method); /* See if there is simply a type match */ - if (result) - goto ret_result; - } + result = typemap_search_helper(debug_display, tm, tm_method, primitive, cqualifiedname, cname, &backup); + if (result) + goto ret_result; + { SwigType *nprim = SwigType_default(primitive); Delete(primitive); @@ -862,8 +797,6 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type result = backup; ret_result: - Delete(template_prefix); - Delete(noarrays); Delete(primitive); if ((unstripped) && (unstripped != type)) Delete(unstripped); From 7a6acb670a2d2541dc31e16e73aded24ff089088 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 3 Feb 2010 07:41:21 +0000 Subject: [PATCH 326/352] remove out of date perl version for testing git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11840 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/perl5/index.html | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/Examples/perl5/index.html b/Examples/perl5/index.html index 254bd41f5..5648c587d 100644 --- a/Examples/perl5/index.html +++ b/Examples/perl5/index.html @@ -66,24 +66,6 @@ The examples have been extensively tested on the following platforms: Please see the Windows page in the main manual for information on using the examples on Windows.

      -The most recent version of Perl used for testing is as follows: - -

      -
      -% perl -version
      -This is perl, v5.6.0 built for sun4-solaris
      -
      -Copyright 1987-2000, Larry Wall
      -
      -Perl may be copied only under the terms of either the Artistic License or the
      -GNU General Public License, which may be found in the Perl 5.0 source kit.
      -
      -Complete documentation for Perl, including FAQ lists, should be found on
      -this system using `man perl' or `perldoc perl'.  If you have access to the
      -Internet, point your browser at http://www.perl.com/, the Perl Home Page.
      -
      -
      -

      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 From 751b8d3b4509875de72e29aafedde4571c4cf918 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 5 Feb 2010 22:22:35 +0000 Subject: [PATCH 327/352] Fix #2894405 - assertion when using -xmlout. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11841 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/main.cxx | 7 ++++++- Source/Modules/swigmain.cxx | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b1070d3c7..458095d3d 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.41 (in progress) ============================ +2010-02-05: wsfulton + Fix #2894405 - assertion when using -xmlout. + 2010-01-28: wsfulton Fix typemap matching bug when a templated type has a typemap both specialized and not specialized. For example: diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 34914efa3..201d42b93 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -25,7 +25,7 @@ char cvsroot_main_cxx[] = "$Id$"; // Global variables -Language *lang; // Language method +static Language *lang = 0; // Language method int CPlusPlus = 0; int Extend = 0; // Extend flag int ForceExtern = 0; // Force extern mode @@ -1231,6 +1231,8 @@ int SWIG_main(int argc, char *argv[], Language *l) { Swig_print_tree(Getattr(top, "module")); } if (dump_xml && top) { + delete lang; + lang = 0; Swig_print_xml(top, xmlout); } Delete(top); @@ -1265,6 +1267,9 @@ int SWIG_main(int argc, char *argv[], Language *l) { if ((werror) && (Swig_warn_count())) { return Swig_warn_count(); } + + delete lang; + return Swig_error_count(); } diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 4208a8c6f..2acdffa9b 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -196,7 +196,8 @@ int main(int margc, char **margv) { dl = (fac) (); } } + int res = SWIG_main(argc, argv, dl); - delete dl; + return res; } From 4d028a0307dac9f5a012fed6f20a84e23c612a0f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Feb 2010 01:46:58 +0000 Subject: [PATCH 328/352] Fix #2918902 - language specific files not being generated in correct directory on Windows when using forward slashes and -o git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11842 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Source/Modules/main.cxx | 18 ++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 458095d3d..511486dcc 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.41 (in progress) ============================ +2010-02-06: wsfulton + Fix #2918902 - language specific files not being generated in correct directory on + Windows when using forward slashes for -o, for example: + swig -python -c++ -o subdirectory/theinterface_wrap.cpp subdirectory/theinterface.i + 2010-02-05: wsfulton Fix #2894405 - assertion when using -xmlout. diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 201d42b93..d42042ebe 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -164,8 +164,8 @@ static int help = 0; static int checkout = 0; static int cpp_only = 0; static int no_cpp = 0; -static char *outfile_name = 0; -static char *outfile_name_h = 0; +static String *outfile_name = 0; +static String *outfile_name_h = 0; static int tm_debug = 0; static int dump_symtabs = 0; static int dump_symbols = 0; @@ -571,16 +571,17 @@ void SWIG_getoptions(int argc, char *argv[]) { } else if (strcmp(argv[i], "-o") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { - outfile_name = Swig_copy_string(argv[i + 1]); + outfile_name = NewString(argv[i + 1]); + Swig_filename_correct(outfile_name); if (!outfile_name_h || !dependencies_file) { - char *ext = strrchr(outfile_name, '.'); - String *basename = ext ? NewStringWithSize(outfile_name, ext - outfile_name) : NewString(outfile_name); + char *ext = strrchr(Char(outfile_name), '.'); + String *basename = ext ? NewStringWithSize(Char(outfile_name), Char(ext) - Char(outfile_name)) : NewString(outfile_name); if (!dependencies_file) { dependencies_file = NewStringf("%s.%s", basename, depends_extension); } if (!outfile_name_h) { Printf(basename, ".%s", hpp_extension); - outfile_name_h = Swig_copy_string(Char(basename)); + outfile_name_h = NewString(basename); } Delete(basename); } @@ -592,7 +593,8 @@ void SWIG_getoptions(int argc, char *argv[]) { } else if (strcmp(argv[i], "-oh") == 0) { Swig_mark_arg(i); if (argv[i + 1]) { - outfile_name_h = Swig_copy_string(argv[i + 1]); + outfile_name_h = NewString(argv[i + 1]); + Swig_filename_correct(outfile_name_h); Swig_mark_arg(i + 1); i++; } else { @@ -961,7 +963,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { // If the user has requested to check out a file, handle that if (checkout) { DOH *s; - char *outfile = Char(input_file); + String *outfile = input_file; if (outfile_name) outfile = outfile_name; From 365afcd017cbbe4a4a034f10043e0f20fe74e148 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Feb 2010 13:42:45 +0000 Subject: [PATCH 329/352] minor code tidy up git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11843 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/main.cxx | 7 +++---- Source/Modules/swigmod.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index d42042ebe..c5a592833 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -182,14 +182,13 @@ static int depend = 0; static int depend_only = 0; static int memory_debug = 0; static int allkw = 0; -static DOH *libfiles = 0; static DOH *cpps = 0; static String *dependencies_file = 0; -static File *f_dependencies_file = 0; static String *dependencies_target = 0; static int external_runtime = 0; static String *external_runtime_name = 0; enum { STAGE1=1, STAGE2=2, STAGE3=4, STAGE4=8, STAGEOVERFLOW=16 }; +static List *libfiles = 0; static List *all_output_files = 0; // ----------------------------------------------------------------------------- @@ -836,7 +835,6 @@ void SWIG_getoptions(int argc, char *argv[]) { int SWIG_main(int argc, char *argv[], Language *l) { char *c; - extern void Swig_print_xml(Node *obj, String *filename); /* Initialize the SWIG core */ Swig_init(); @@ -1045,6 +1043,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (depend) { if (!no_cpp) { String *outfile; + File *f_dependencies_file = 0; char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(input_file): Char(input_file)); if (!outfile_name) { @@ -1244,7 +1243,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (memory_debug) DohMemoryDebug(); - char *outfiles = getenv("CCACHE_OUTFILES"); + const char *outfiles = getenv("CCACHE_OUTFILES"); if (outfiles) { File *f_outfiles = NewFile(outfiles, "w", 0); if (!f_outfiles) { diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 440e0e960..eaaca7688 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -321,6 +321,7 @@ void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */ void SWIG_config_file(const_String_or_char_ptr ); const String *SWIG_output_directory(); void SWIG_config_cppext(const char *ext); +void Swig_print_xml(Node *obj, String *filename); /* get the list of generated files */ List *SWIG_output_files(); From 81d5e6c7f543ee734d7b94e70eff3e926d0bc4dd Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 6 Feb 2010 14:12:03 +0000 Subject: [PATCH 330/352] compile fix after last checkin git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11844 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/main.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index c5a592833..6a038f1ff 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1243,7 +1243,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (memory_debug) DohMemoryDebug(); - const char *outfiles = getenv("CCACHE_OUTFILES"); + char *outfiles = getenv("CCACHE_OUTFILES"); if (outfiles) { File *f_outfiles = NewFile(outfiles, "w", 0); if (!f_outfiles) { From b40a8e38ab602aecfa6f20065a7531b5e9776994 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Feb 2010 23:09:22 +0000 Subject: [PATCH 331/352] Correct syntax of %includefile and %importfile in comment git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11846 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/parser.y | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index cc04f2be2..6f42d2398 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -2101,8 +2101,8 @@ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK { ; /* ------------------------------------------------------------ - %includefile "filename" [option1="xyz", ...] [ declarations ] - %importfile "filename" [option1="xyz", ...] [ declarations ] + %includefile(option1="xyz", ...) "filename" [ declarations ] + %importfile(option1="xyz", ...) "filename" [ declarations ] ------------------------------------------------------------ */ include_directive: includetype options string LBRACKET { From 207ba5ce39ae37b8c07c477367b049682248b860 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Feb 2010 23:12:27 +0000 Subject: [PATCH 332/352] Fix #1807329 - When Makefile dependencies are being generated using the -M family of options on Windows, the file paths have been corrected to use single backslashes rather than double backslashes as path separators. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11847 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 5 +++++ Source/Modules/main.cxx | 2 +- Source/Preprocessor/cpp.c | 9 +++++---- Source/Swig/include.c | 5 ++--- Source/Swig/misc.c | 17 +++++++++++++++-- Source/Swig/swig.h | 3 ++- 6 files changed, 30 insertions(+), 11 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 511486dcc..e84bb7ad5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,11 @@ Version 1.3.41 (in progress) ============================ +2010-02-08: wsfulton + Fix #1807329 - When Makefile dependencies are being generated using the -M family of options + on Windows, the file paths have been corrected to use single backslashes rather than double + backslashes as path separators. + 2010-02-06: wsfulton Fix #2918902 - language specific files not being generated in correct directory on Windows when using forward slashes for -o, for example: diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 6a038f1ff..7dbb4f486 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1022,7 +1022,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (lang_config) { Printf(fs, "\n%%include <%s>\n", lang_config); } - Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_last_file()); + Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_filename_escape(Swig_last_file())); for (i = 0; i < Len(libfiles); i++) { Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i)); } diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 7958b4e09..c4c5d6861 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -625,7 +625,7 @@ unterm: /* ----------------------------------------------------------------------------- * DOH *get_filename(DOH *str) * - * Read a filename from str. A filename can be enclose in quotes, angle brackets, + * Read a filename from str. A filename can be enclosed in quotes, angle brackets, * or bare. * ----------------------------------------------------------------------------- */ @@ -652,6 +652,7 @@ static String *get_filename(String *str, int *sysfile) { if (isspace(c)) Ungetc(c, str); } + Swig_filename_unescape(fn); Swig_filename_correct(fn); Seek(fn, 0, SEEK_SET); return fn; @@ -1593,9 +1594,9 @@ String *Preprocessor_parse(String *s) { s1 = cpp_include(fn, sysfile); if (s1) { if (include_all) - Printf(ns, "%%includefile \"%s\" [\n", Swig_last_file()); + Printf(ns, "%%includefile \"%s\" [\n", Swig_filename_escape(Swig_last_file())); else if (import_all) { - Printf(ns, "%%importfile \"%s\" [\n", Swig_last_file()); + Printf(ns, "%%importfile \"%s\" [\n", Swig_filename_escape(Swig_last_file())); push_imported(); } @@ -1732,7 +1733,7 @@ String *Preprocessor_parse(String *s) { char *dirname; add_chunk(ns, chunk, allow); copy_location(s, chunk); - Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_last_file()); + Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file())); if (Equal(decl, kpp_dimport)) { push_imported(); } diff --git a/Source/Swig/include.c b/Source/Swig/include.c index f42eb5d45..dd4c7e020 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -184,9 +184,8 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_ } if (f) { Delete(lastpath); - lastpath = Swig_filename_escape(filename); + lastpath = filename; } - Delete(filename); return f; } @@ -244,7 +243,7 @@ static String *Swig_include_any(const_String_or_char_ptr name, int sysfile) { str = Swig_read_file(f); fclose(f); Seek(str, 0, SEEK_SET); - file = Copy(lastpath); + file = Copy(Swig_last_file()); Setfile(str, file); Delete(file); Setline(str, 1); diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 3a42ab682..1fd8f7f90 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -159,12 +159,25 @@ void Swig_filename_correct(String *filename) { String *Swig_filename_escape(String *filename) { String *adjusted_filename = Copy(filename); #if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */ - Replaceall(adjusted_filename, "\\\\", "\\"); /* remove double '\' in case any already present */ - Replaceall(adjusted_filename, "\\", "\\\\"); + Replaceall(adjusted_filename, "\\\\", "\\"); /* remove double '\' in case any already present */ + Replaceall(adjusted_filename, "\\", "\\\\"); #endif return adjusted_filename; } +/* ----------------------------------------------------------------------------- + * Swig_filename_unescape() + * + * Remove double backslash escaping in filename - for Windows + * ----------------------------------------------------------------------------- */ + +void Swig_filename_unescape(String *filename) { + (void)filename; +#if defined(_WIN32) + Replaceall(filename, "\\\\", "\\"); +#endif +} + /* ----------------------------------------------------------------------------- * Swig_string_escape() * diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 6abe6f5c5..4bd08be3a 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -294,8 +294,9 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern void Swig_banner(File *f); extern void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar); extern String *Swig_strip_c_comments(const String *s); - extern String *Swig_filename_escape(String *filename); extern void Swig_filename_correct(String *filename); + extern String *Swig_filename_escape(String *filename); + extern void Swig_filename_unescape(String *filename); extern String *Swig_string_escape(String *s); extern String *Swig_string_mangle(const String *s); extern void Swig_scopename_split(const String *s, String **prefix, String **last); From e810d025c9b15f0e9e58a373f42a5cc0672c4bc4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 8 Feb 2010 23:21:14 +0000 Subject: [PATCH 333/352] Slight text change for the language subdirectory when using verbose output and change to use Printf rather than printf git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11848 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/main.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 7dbb4f486..e463d1d14 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -564,8 +564,8 @@ void SWIG_getoptions(int argc, char *argv[]) { Swig_mark_arg(i); } else if (strcmp(argv[i], "-swiglib") == 0) { if (SwigLibWin) - printf("%s\n", Char(SwigLibWin)); - printf("%s\n", SwigLib); + Printf(stdout, "%s\n", Char(SwigLibWin)); + Printf(stdout, "%s\n", SwigLib); SWIG_exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-o") == 0) { Swig_mark_arg(i); @@ -941,8 +941,8 @@ int SWIG_main(int argc, char *argv[], Language *l) { Swig_add_directory((String *) SwigLib); if (Verbose) { - printf("LangSubDir: %s\n", Char(LangSubDir)); - printf("Search paths:\n"); + Printf(stdout, "Language subdirectory: %s\n", LangSubDir); + Printf(stdout, "Search paths:\n"); List *sp = Swig_search_path(); Iterator s; for (s = First(sp); s.item; s = Next(s)) { @@ -966,7 +966,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { outfile = outfile_name; if (Verbose) - printf("Handling checkout...\n"); + Printf(stdout, "Handling checkout...\n"); s = Swig_include(input_file); if (!s) { @@ -992,7 +992,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { } else { // Run the preprocessor if (Verbose) - printf("Preprocessing...\n"); + Printf(stdout, "Preprocessing...\n"); { int i; From d0ecd36ade0689c255d2f8e90541d663d25e799a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Feb 2010 00:21:03 +0000 Subject: [PATCH 334/352] Add Swig_filename_escape for library files added with -l ... not entirely sure this is needed, but no harm done git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11849 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/main.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index e463d1d14..43f6af835 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1024,7 +1024,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { } Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_filename_escape(Swig_last_file())); for (i = 0; i < Len(libfiles); i++) { - Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i)); + Printf(fs, "\n%%include \"%s\"\n", Swig_filename_escape(Getitem(libfiles, i))); } Seek(fs, 0, SEEK_SET); cpps = Preprocessor_parse(fs); From 791fabbd5184ae553feb01dcb1e33502e889504c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 9 Feb 2010 23:39:31 +0000 Subject: [PATCH 335/352] Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as they should be git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11851 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/main.cxx | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index e84bb7ad5..7e859f9eb 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2010-02-09: wsfulton + Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as + they should be. + 2010-02-08: wsfulton Fix #1807329 - When Makefile dependencies are being generated using the -M family of options on Windows, the file paths have been corrected to use single backslashes rather than double diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 43f6af835..4a0a0b932 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -564,7 +564,7 @@ void SWIG_getoptions(int argc, char *argv[]) { Swig_mark_arg(i); } else if (strcmp(argv[i], "-swiglib") == 0) { if (SwigLibWin) - Printf(stdout, "%s\n", Char(SwigLibWin)); + Printf(stdout, "%s\n", SwigLibWin); Printf(stdout, "%s\n", SwigLib); SWIG_exit(EXIT_SUCCESS); } else if (strcmp(argv[i], "-o") == 0) { @@ -1077,9 +1077,13 @@ int SWIG_main(int argc, char *argv[], Language *l) { } List *files = Preprocessor_depend(); for (int i = 0; i < Len(files); i++) { - if ((depend != 2) || ((depend == 2) && (Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) != 0))) { - Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i)); - } + int use_file = 1; + if (depend == 2) { + if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || SwigLibWin && (Strncmp(Getitem(files, i), SwigLibWin, Len(SwigLibWin)) == 0)) + use_file = 0; + } + if (use_file) + Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i)); } Printf(f_dependencies_file, "\n"); if (f_dependencies_file != stdout) From 65f1e47cb274afdf48cf127d9e9c2e5ef5630f28 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 11 Feb 2010 21:59:16 +0000 Subject: [PATCH 336/352] remove some unnecessary casts git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11853 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/csharp.cxx | 6 +++--- Source/Modules/java.cxx | 6 +++--- Source/Modules/modula3.cxx | 6 +++--- Source/Modules/pike.cxx | 4 ++-- Source/Modules/ruby.cxx | 6 +++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 7fb481271..b8f3c0631 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -379,10 +379,10 @@ public: Printf(f_runtime, "\n"); - Swig_name_register((char *) "wrapper", (char *) "CSharp_%f"); + Swig_name_register("wrapper", "CSharp_%f"); if (old_variable_names) { - Swig_name_register((char *) "set", (char *) "set_%v"); - Swig_name_register((char *) "get", (char *) "get_%v"); + Swig_name_register("set", "set_%v"); + Swig_name_register("get", "get_%v"); } Printf(f_wrappers, "\n#ifdef __cplusplus\n"); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 5eb6dcae9..548048653 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -402,10 +402,10 @@ public: Printf(wrapper_name, "Java_%s%s_%%f", Char(jnipackage), jniname); Delete(jniname); - Swig_name_register((char *) "wrapper", Char(wrapper_name)); + Swig_name_register("wrapper", Char(wrapper_name)); if (old_variable_names) { - Swig_name_register((char *) "set", (char *) "set_%v"); - Swig_name_register((char *) "get", (char *) "get_%v"); + Swig_name_register("set", "set_%v"); + Swig_name_register("get", "get_%v"); } Delete(wrapper_name); diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index 7440d906a..f5878c37c 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -966,10 +966,10 @@ MODULA3(): Printf(f_runtime, "#define SWIGMODULA3\n"); Printf(f_runtime, "\n"); - Swig_name_register((char *) "wrapper", (char *) "Modula3_%f"); + Swig_name_register("wrapper", "Modula3_%f"); if (old_variable_names) { - Swig_name_register((char *) "set", (char *) "set_%v"); - Swig_name_register((char *) "get", (char *) "get_%v"); + Swig_name_register("set", "set_%v"); + Swig_name_register("get", "get_%v"); } Printf(f_wrappers, "\n#ifdef __cplusplus\n"); diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index 98f63056c..a6da60ce5 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -762,7 +762,7 @@ public: /* Create a function to set the values of the (mutable) variables */ if (need_setter) { Wrapper *wrapper = NewWrapper(); - String *setter = Swig_name_member(getClassPrefix(), (char *) "`->="); + String *setter = Swig_name_member(getClassPrefix(), "`->="); String *wname = Swig_name_wrapper(setter); Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL); Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n"); @@ -801,7 +801,7 @@ public: /* Create a function to get the values of the (mutable) variables */ Wrapper *wrapper = NewWrapper(); - String *getter = Swig_name_member(getClassPrefix(), (char *) "`->"); + String *getter = Swig_name_member(getClassPrefix(), "`->"); String *wname = Swig_name_wrapper(getter); Printv(wrapper->def, "static void ", wname, "(INT32 args) {", NIL); Printf(wrapper->locals, "char *name = (char *) STR0(Pike_sp[0-args].u.string);\n"); diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index a28256753..c0a252542 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -2574,7 +2574,7 @@ public: /* First wrap the allocate method */ current = CONSTRUCTOR_ALLOCATE; - Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate"); + Swig_name_register("construct", "%c_allocate"); Language::constructorHandler(n); @@ -2609,7 +2609,7 @@ public: Delete(docs); current = CONSTRUCTOR_INITIALIZE; - Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "new_%c"); + Swig_name_register("construct", "new_%c"); Language::constructorHandler(n); /* Restore original parameter list */ @@ -2631,7 +2631,7 @@ public: /* First wrap the allocate method */ current = CONSTRUCTOR_ALLOCATE; - Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate"); + Swig_name_register("construct", "%c_allocate"); return Language::copyconstructorHandler(n); } From f4cfc9bce53b6741c9c6bda5978931f82b68527e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 11 Feb 2010 22:56:39 +0000 Subject: [PATCH 337/352] Add the -debug-lsymbols option for displaying the target language layer symbols. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11854 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Doc/Manual/Extending.html | 1 + Source/Modules/lang.cxx | 32 ++++++++++++++++++++++++++++---- Source/Modules/main.cxx | 13 ++++++++++++- Source/Modules/swigmod.h | 6 ++++++ 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 7e859f9eb..fabd5566f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.41 (in progress) ============================ +2010-02-11: wsfulton + Add the -debug-lsymbols option for displaying the target language layer symbols. + 2010-02-09: wsfulton Fix -MM and -MMD options on Windows. They were not omitting files in the SWIG library as they should be. diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 040eb65c7..cc40024e6 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -3601,6 +3601,7 @@ There are various command line options which can aid debugging a SWIG interface -debug-symtabs - Display symbol tables information -debug-symbols - Display target language symbols in the symbol tables -debug-csymbols - Display C symbols in the symbol tables +-debug-lsymbols - Display target language layer symbols -debug-tags - Display information about the tags found in the interface -debug-template - Display information for debugging templates -debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index d381e20b9..8b5635376 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -308,12 +308,14 @@ none_comparison(NewString("$arg != 0")), director_ctor_code(NewString("")), director_prot_ctor_code(0), symbols(NewHash()), +symbolDump(NewString("")), classtypes(NewHash()), enumtypes(NewHash()), overloading(0), multiinput(0), cplus_runtime(0), -directors(0) { +directors(0), +symbol_table_dump(0) { argc_template_string = NewString("argc"); argv_template_string = NewString("argv[%d]"); @@ -333,6 +335,7 @@ directors(0) { Language::~Language() { Delete(symbols); + Delete(symbolDump); Delete(classtypes); Delete(enumtypes); Delete(director_ctor_code); @@ -2916,18 +2919,35 @@ void Language::main(int argc, char *argv[]) { * Prints an error message and returns 0 if a conflict occurs. * ----------------------------------------------------------------------------- */ -int -Language::addSymbol(const String *s, const Node *n) { +int Language::addSymbol(const String *s, const Node *n) { Node *c = Getattr(symbols, s); if (c && (c != n)) { - Swig_error(input_file, line_number, "'%s' is multiply defined in the generated module.\n", s); + Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module.\n", s); Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s); return 0; } Setattr(symbols, s, n); + if (symbol_table_dump) + Printf(symbolDump, "%s\n", s); return 1; } +/* ----------------------------------------------------------------------------- + * Language::dumpSymbols() + * ----------------------------------------------------------------------------- */ + +void Language::dumpSymbols() { + if (symbol_table_dump) { + Printf(stdout, "LANGUAGE SYMBOLS start =======================================\n"); + + /* The symbol table is a hash so no ordering is possible if we iterate through it. + * Instead we gather the symbols as they are added and display them here. */ + Printf(stdout, "%s", symbolDump); + + Printf(stdout, "LANGUAGE SYMBOLS finish =======================================\n"); + } +} + /* ----------------------------------------------------------------------------- * Language::symbolLookup() * ----------------------------------------------------------------------------- */ @@ -3376,6 +3396,10 @@ void Language::setOverloadResolutionTemplates(String *argc, String *argv) { argv_template_string = Copy(argv); } +void Language::setSymbolsDumpNeeded() { + symbol_table_dump = 1; +} + int Language::is_assignable(Node *n) { if (GetFlag(n, "feature:immutable")) return 0; diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 4a0a0b932..beabada74 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -65,6 +65,7 @@ static const char *usage1 = (const char *) "\ -debug-symtabs - Display symbol tables information\n\ -debug-symbols - Display target language symbols in the symbol tables\n\ -debug-csymbols - Display C symbols in the symbol tables\n\ + -debug-lsymbols - Display target language layer symbols\n\ -debug-tags - Display information about the tags found in the interface\n\ -debug-template - Display information for debugging templates\n\ -debug-top - Display entire parse tree at stages 1-4, is a csv list of stages\n\ @@ -170,6 +171,7 @@ static int tm_debug = 0; static int dump_symtabs = 0; static int dump_symbols = 0; static int dump_csymbols = 0; +static int dump_lang_symbols = 0; static int dump_tags = 0; static int dump_module = 0; static int dump_top = 0; @@ -740,6 +742,9 @@ void SWIG_getoptions(int argc, char *argv[]) { } else if (strcmp(argv[i], "-debug-csymbols") == 0) { dump_csymbols = 1; Swig_mark_arg(i); + } else if (strcmp(argv[i], "-debug-lsymbols") == 0) { + dump_lang_symbols = 1; + Swig_mark_arg(i); } else if ((strcmp(argv[i], "-debug-tags") == 0) || (strcmp(argv[i], "-dump_tags") == 0)) { dump_tags = 1; Swig_mark_arg(i); @@ -903,6 +908,9 @@ int SWIG_main(int argc, char *argv[], Language *l) { SWIG_getoptions(argc, argv); + if (dump_lang_symbols) + lang->setSymbolsDumpNeeded(); + // Define the __cplusplus symbol if (CPlusPlus) Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0); @@ -1079,7 +1087,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { for (int i = 0; i < Len(files); i++) { int use_file = 1; if (depend == 2) { - if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || SwigLibWin && (Strncmp(Getitem(files, i), SwigLibWin, Len(SwigLibWin)) == 0)) + if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWin && (Strncmp(Getitem(files, i), SwigLibWin, Len(SwigLibWin)) == 0))) use_file = 0; } if (use_file) @@ -1227,6 +1235,9 @@ int SWIG_main(int argc, char *argv[], Language *l) { } } } + if (dump_lang_symbols) { + lang->dumpSymbols(); + } if (dump_top & STAGE4) { Printf(stdout, "debug-top stage 4\n"); Swig_print_tree(top); diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index eaaca7688..64fe5d020 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -209,6 +209,7 @@ public: /* Miscellaneous */ virtual int validIdentifier(String *s); /* valid identifier? */ virtual int addSymbol(const String *s, const Node *n); /* Add symbol */ + virtual void dumpSymbols(); virtual Node *symbolLookup(String *s); /* Symbol lookup */ virtual Node *classLookup(SwigType *s); /* Class lookup */ virtual Node *enumLookup(SwigType *s); /* Enum lookup */ @@ -251,6 +252,9 @@ public: /* Set overload variable templates argc and argv */ void setOverloadResolutionTemplates(String *argc, String *argv); + /* Set language module symbol table dump option */ + void setSymbolsDumpNeeded(); + /* Language instance is a singleton - get instance */ static Language* instance(); @@ -305,12 +309,14 @@ protected: private: Hash *symbols; + String *symbolDump; Hash *classtypes; Hash *enumtypes; int overloading; int multiinput; int cplus_runtime; int directors; + int symbol_table_dump; static Language *this_; }; From 6c275f00d976520c487f143faaac9cdfc7737cac Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 12 Feb 2010 23:20:58 +0000 Subject: [PATCH 338/352] Add in possibility to use scopes in target language module symbol table git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11855 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/lang.cxx | 80 +++++++++++++++++++++++++--------------- Source/Modules/main.cxx | 3 -- Source/Modules/swigmod.h | 11 ++---- Source/Swig/symbol.c | 6 +-- 4 files changed, 57 insertions(+), 43 deletions(-) diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 8b5635376..56301e72d 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -307,15 +307,15 @@ Language::Language(): none_comparison(NewString("$arg != 0")), director_ctor_code(NewString("")), director_prot_ctor_code(0), -symbols(NewHash()), -symbolDump(NewString("")), +symtabs(NewHash()), classtypes(NewHash()), enumtypes(NewHash()), overloading(0), multiinput(0), cplus_runtime(0), -directors(0), -symbol_table_dump(0) { +directors(0) { + Hash *symbols = NewHash(); + Setattr(symtabs, "", symbols); // create top level/global symbol table scope argc_template_string = NewString("argc"); argv_template_string = NewString("argv[%d]"); @@ -334,8 +334,7 @@ symbol_table_dump(0) { } Language::~Language() { - Delete(symbols); - Delete(symbolDump); + Delete(symtabs); Delete(classtypes); Delete(enumtypes); Delete(director_ctor_code); @@ -1140,7 +1139,7 @@ int Language::callbackfunctionHandler(Node *n) { Setattr(n, "type", cbty); Setattr(n, "value", calltype); - Node *ns = Getattr(symbols, cbname); + Node *ns = symbolLookup(cbname); if (!ns) constantWrapper(n); @@ -2462,7 +2461,7 @@ int Language::classHandler(Node *n) { continue; String *methodname = Getattr(method, "sym:name"); String *wrapname = NewStringf("%s_%s", symname, methodname); - if (!Getattr(symbols, wrapname) && (!is_public(method))) { + if (!symbolLookup(wrapname, "") && (!is_public(method))) { Node *m = Copy(method); Setattr(m, "director", "1"); Setattr(m, "parentNode", n); @@ -2915,20 +2914,34 @@ void Language::main(int argc, char *argv[]) { /* ----------------------------------------------------------------------------- * Language::addSymbol() * - * Adds a symbol entry. Returns 1 if the symbol is added successfully. + * Adds a symbol entry into the target language symbol tables. + * Returns 1 if the symbol is added successfully. * Prints an error message and returns 0 if a conflict occurs. + * The scope is optional for target languages and if supplied must be a fully + * resolved scope and the symbol s must not contain any scope qualifiers. * ----------------------------------------------------------------------------- */ -int Language::addSymbol(const String *s, const Node *n) { - Node *c = Getattr(symbols, s); - if (c && (c != n)) { - Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module.\n", s); - Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s); - return 0; +int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope) { + Hash *symbols = Getattr(symtabs, scope); + if (!symbols) { + // New scope which has not been added by the target language - lazily created. + symbols = NewHash(); + Setattr(symtabs, scope, symbols); + + // Add the new scope as a symbol in the top level scope. + // Alternatively the target language must add it in before attempting to add symbols into the scope. + const_String_or_char_ptr top_scope = ""; + Hash *topscope_symbols = Getattr(symtabs, top_scope); + Setattr(topscope_symbols, scope, NewHash()); + } else { + Node *c = Getattr(symbols, s); + if (c && (c != n)) { + Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module.\n", s); + Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s); + return 0; + } } Setattr(symbols, s, n); - if (symbol_table_dump) - Printf(symbolDump, "%s\n", s); return 1; } @@ -2937,22 +2950,35 @@ int Language::addSymbol(const String *s, const Node *n) { * ----------------------------------------------------------------------------- */ void Language::dumpSymbols() { - if (symbol_table_dump) { - Printf(stdout, "LANGUAGE SYMBOLS start =======================================\n"); + Printf(stdout, "LANGUAGE SYMBOLS start =======================================\n"); - /* The symbol table is a hash so no ordering is possible if we iterate through it. - * Instead we gather the symbols as they are added and display them here. */ - Printf(stdout, "%s", symbolDump); - - Printf(stdout, "LANGUAGE SYMBOLS finish =======================================\n"); + Node *table = symtabs; + Iterator ki = First(table); + while (ki.key) { + String *k = ki.key; + Printf(stdout, "===================================================\n"); + Printf(stdout, "%s -\n", k); + { + Symtab *symtab = Getattr(table, k); + Iterator it = First(symtab); + while (it.key) { + String *symname = it.key; + Printf(stdout, " %s\n", symname); + it = Next(it); + } + } + ki = Next(ki); } + + Printf(stdout, "LANGUAGE SYMBOLS finish =======================================\n"); } /* ----------------------------------------------------------------------------- * Language::symbolLookup() * ----------------------------------------------------------------------------- */ -Node *Language::symbolLookup(String *s) { +Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) { + Hash *symbols = Getattr(symtabs, scope); return Getattr(symbols, s); } @@ -3396,10 +3422,6 @@ void Language::setOverloadResolutionTemplates(String *argc, String *argv) { argv_template_string = Copy(argv); } -void Language::setSymbolsDumpNeeded() { - symbol_table_dump = 1; -} - int Language::is_assignable(Node *n) { if (GetFlag(n, "feature:immutable")) return 0; diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index beabada74..54b210888 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -908,9 +908,6 @@ int SWIG_main(int argc, char *argv[], Language *l) { SWIG_getoptions(argc, argv); - if (dump_lang_symbols) - lang->setSymbolsDumpNeeded(); - // Define the __cplusplus symbol if (CPlusPlus) Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0); diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 64fe5d020..72bfa415e 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -208,9 +208,9 @@ public: /* Miscellaneous */ virtual int validIdentifier(String *s); /* valid identifier? */ - virtual int addSymbol(const String *s, const Node *n); /* Add symbol */ + virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */ virtual void dumpSymbols(); - virtual Node *symbolLookup(String *s); /* Symbol lookup */ + virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */ virtual Node *classLookup(SwigType *s); /* Class lookup */ virtual Node *enumLookup(SwigType *s); /* Enum lookup */ virtual int abstractClassTest(Node *n); /* Is class really abstract? */ @@ -252,9 +252,6 @@ public: /* Set overload variable templates argc and argv */ void setOverloadResolutionTemplates(String *argc, String *argv); - /* Set language module symbol table dump option */ - void setSymbolsDumpNeeded(); - /* Language instance is a singleton - get instance */ static Language* instance(); @@ -308,15 +305,13 @@ protected: int director_language; private: - Hash *symbols; - String *symbolDump; + Hash *symtabs; /* symbol tables */ Hash *classtypes; Hash *enumtypes; int overloading; int multiinput; int cplus_runtime; int directors; - int symbol_table_dump; static Language *this_; }; diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index e018029a1..94fb7c21e 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -207,14 +207,14 @@ void Swig_symbol_print_tables_summary(void) { * ----------------------------------------------------------------------------- */ static void symbol_print_symbols(const char *symboltabletype) { - Node *obj = symtabs; - Iterator ki = First(obj); + Node *table = symtabs; + Iterator ki = First(table); while (ki.key) { String *k = ki.key; Printf(stdout, "===================================================\n"); Printf(stdout, "%s -\n", k); { - Symtab *symtab = Getattr(Getattr(obj, k), symboltabletype); + Symtab *symtab = Getattr(Getattr(table, k), symboltabletype); Iterator it = First(symtab); while (it.key) { String *symname = it.key; From 6fe7287ad359b22a9dc1912378e8d0ec5995fae8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Feb 2010 00:09:24 +0000 Subject: [PATCH 339/352] Update error message git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11856 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/SWIGPlus.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html index bd8a7ab5d..d1498224f 100644 --- a/Doc/Manual/SWIGPlus.html +++ b/Doc/Manual/SWIGPlus.html @@ -3836,7 +3836,7 @@ When this conflict occurs, you will get an error message that resembles this:

      -example.i:26. Error. 'foo' is multiply defined in the generated module.
      +example.i:26. Error. 'foo' is multiply defined in the generated target language module.
       example.i:23. Previous declaration of 'foo'
       
      From 4bf50493979147490c88ba2d7209ad072109e27d Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Feb 2010 00:42:09 +0000 Subject: [PATCH 340/352] Improve target language symbol tables for Java and C#, using different scopes for the constants interface, module class and intermediary class rather than incorrectly putting all the symbols into one scope git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11857 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 11 +++++++++++ Examples/test-suite/common.mk | 1 + Examples/test-suite/symbol_clash.i | 28 ++++++++++++++++++++++++++++ Source/Modules/csharp.cxx | 17 +++++++++++------ Source/Modules/java.cxx | 30 ++++++++++++++++++++---------- 5 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 Examples/test-suite/symbol_clash.i diff --git a/CHANGES.current b/CHANGES.current index fabd5566f..c312cfe25 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,17 @@ Version 1.3.41 (in progress) ============================ +2010-02-13: wsfulton + [C#, Java] Fix incorrect multiply defined symbol name error when an enum item + and class name have the same name, as reported by Nathan Krieger. Example: + + class Vector {}; + namespace Text { + enum Preference { Vector }; + } + + This also fixes other incorrect corner case target language symbol name clashes. + 2010-02-11: wsfulton Add the -debug-lsymbols option for displaying the target language layer symbols. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 0dfe73939..d15451aca 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -305,6 +305,7 @@ CPP_TEST_CASES += \ static_const_member_2 \ struct_initialization_cpp \ struct_value \ + symbol_clash \ template \ template_arg_replace \ template_arg_scope \ diff --git a/Examples/test-suite/symbol_clash.i b/Examples/test-suite/symbol_clash.i new file mode 100644 index 000000000..f0aef1398 --- /dev/null +++ b/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/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index b8f3c0631..11daee3c9 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -330,6 +330,10 @@ public: module_class_name = Copy(Getattr(n, "name")); } + // module class and intermediary classes are always created + addSymbol(imclass_name, n); + addSymbol(module_class_name, n); + imclass_class_code = NewString(""); proxy_class_def = NewString(""); proxy_class_code = NewString(""); @@ -671,7 +675,7 @@ public: virtual int nativeWrapper(Node *n) { String *wrapname = Getattr(n, "wrap:name"); - if (!addSymbol(wrapname, n)) + if (!addSymbol(wrapname, n, imclass_name)) return SWIG_ERROR; if (Getattr(n, "type")) { @@ -711,7 +715,7 @@ public: String *overloaded_name = getOverloadedName(n); if (!Getattr(n, "sym:overloaded")) { - if (!addSymbol(Getattr(n, "sym:name"), n)) + if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name)) return SWIG_ERROR; } @@ -1309,11 +1313,13 @@ public: String *return_type = NewString(""); String *constants_code = NewString(""); - if (!addSymbol(symname, n)) - return SWIG_ERROR; - bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); + const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname; + String *scope = proxy_flag && wrapping_member_flag ? proxy_class_name : module_class_name; + if (!addSymbol(itemname, n, scope)) + return SWIG_ERROR; + // The %csconst feature determines how the constant value is obtained int const_feature_flag = GetFlag(n, "feature:cs:const"); @@ -1354,7 +1360,6 @@ public: const String *outattributes = Getattr(n, "tmap:cstype:outattributes"); if (outattributes) Printf(constants_code, " %s\n", outattributes); - const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname; const String *methodmods = Getattr(n, "feature:cs:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 548048653..902fdccf6 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -47,6 +47,7 @@ class JAVA:public Language { String *imclass_name; // intermediary class name String *module_class_name; // module class name + String *constants_interface_name; // constants interface name String *imclass_class_code; // intermediary class code String *proxy_class_def; String *proxy_class_code; @@ -114,6 +115,7 @@ public: member_func_flag(false), imclass_name(NULL), module_class_name(NULL), + constants_interface_name(NULL), imclass_class_code(NULL), proxy_class_def(NULL), proxy_class_code(NULL), @@ -338,6 +340,11 @@ public: else module_class_name = Copy(Getattr(n, "name")); } + constants_interface_name = NewStringf("%sConstants", module_class_name); + + // module class and intermediary classes are always created + addSymbol(imclass_name, n); + addSymbol(module_class_name, n); imclass_class_code = NewString(""); proxy_class_def = NewString(""); @@ -501,12 +508,12 @@ public: Printf(f_module, "extends %s ", module_baseclass); if (Len(module_interfaces) > 0) { if (Len(module_class_constants_code) != 0) - Printv(f_module, "implements ", Getattr(n, "name"), "Constants, ", module_interfaces, " ", NIL); + Printv(f_module, "implements ", constants_interface_name, ", ", module_interfaces, " ", NIL); else Printv(f_module, "implements ", module_interfaces, " ", NIL); } else { if (Len(module_class_constants_code) != 0) - Printv(f_module, "implements ", Getattr(n, "name"), "Constants ", NIL); + Printv(f_module, "implements ", constants_interface_name, " ", NIL); } Printf(f_module, "{\n"); @@ -526,7 +533,7 @@ public: // Generate the Java constants interface if (Len(module_class_constants_code) != 0) { - String *filen = NewStringf("%s%sConstants.java", SWIG_output_directory(), module_class_name); + String *filen = NewStringf("%s%s.java", SWIG_output_directory(), constants_interface_name); File *f_module = NewFile(filen, "w", SWIG_output_files()); if (!f_module) { FileErrorDisplay(filen); @@ -545,7 +552,7 @@ public: if (module_imports) Printf(f_module, "%s\n", module_imports); - Printf(f_module, "public interface %sConstants {\n", module_class_name); + Printf(f_module, "public interface %s {\n", constants_interface_name); // Write out all the global constants Printv(f_module, module_class_constants_code, NIL); @@ -610,6 +617,8 @@ public: imclass_class_modifiers = NULL; Delete(module_class_name); module_class_name = NULL; + Delete(constants_interface_name); + constants_interface_name = NULL; Delete(module_class_code); module_class_code = NULL; Delete(module_baseclass); @@ -739,7 +748,7 @@ public: virtual int nativeWrapper(Node *n) { String *wrapname = Getattr(n, "wrap:name"); - if (!addSymbol(wrapname, n)) + if (!addSymbol(wrapname, n, imclass_name)) return SWIG_ERROR; if (Getattr(n, "type")) { @@ -781,7 +790,7 @@ public: bool is_destructor = (Cmp(Getattr(n, "nodeType"), "destructor") == 0); if (!Getattr(n, "sym:overloaded")) { - if (!addSymbol(Getattr(n, "sym:name"), n)) + if (!addSymbol(Getattr(n, "sym:name"), n, imclass_name)) return SWIG_ERROR; } @@ -1348,11 +1357,13 @@ public: String *return_type = NewString(""); String *constants_code = NewString(""); - if (!addSymbol(symname, n)) - return SWIG_ERROR; - bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); + const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname; + String *scope = proxy_flag && wrapping_member_flag ? proxy_class_name : constants_interface_name; + if (!addSymbol(itemname, n, scope)) + return SWIG_ERROR; + // The %javaconst feature determines how the constant value is obtained int const_feature_flag = GetFlag(n, "feature:java:const"); @@ -1387,7 +1398,6 @@ public: Setattr(n, "value", new_value); } - const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname; const String *methodmods = Getattr(n, "feature:java:methodmodifiers"); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); From cb6e87d0e99bde4bf957b0f350f5d10bec434f25 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Feb 2010 14:22:31 +0000 Subject: [PATCH 341/352] consistent inclusion of ruby.h git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11858 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/ruby/embed.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/ruby/embed.i b/Lib/ruby/embed.i index ad38190eb..9226ef453 100644 --- a/Lib/ruby/embed.i +++ b/Lib/ruby/embed.i @@ -1,6 +1,6 @@ %wrapper %{ -#include "ruby.h" +#include int main(argc, argv) From 12b89ff406c907aeb6ca5f512ac306b1d21e13d9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Feb 2010 15:06:26 +0000 Subject: [PATCH 342/352] Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11859 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Lib/ruby/rubycontainer.swg | 21 +++++++++------------ Lib/ruby/std_pair.i | 10 ++++------ Lib/ruby/std_set.i | 7 +++---- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c312cfe25..7c47470fa 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2010-02-13: wsfulton + [Ruby] Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x + used in various STL wrappers. + 2010-02-13: wsfulton [C#, Java] Fix incorrect multiply defined symbol name error when an enum item and class name have the same name, as reported by Nathan Krieger. Example: diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index df3f520d8..8008654c6 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -446,11 +446,10 @@ namespace swig %typemap(out,noblock=1,fragment="RubySequence_Cont") std::pair { $result = rb_ary_new2(2); - RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first), - swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); - RARRAY_PTR($result)[1] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second), - swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); - RARRAY_LEN($result) = 2; + rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first), + swig::ConstIterator::descriptor(),SWIG_POINTER_OWN)); + rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second), + swig::ConstIterator::descriptor(),SWIG_POINTER_OWN)); } // std::map/multimap/set allow returning std::pair< iterator, iterator > from @@ -459,11 +458,10 @@ namespace swig %typemap(out,noblock=1,fragment="RubySequence_Cont") std::pair { $result = rb_ary_new2(2); - RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first), - swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); - RARRAY_PTR($result)[1] = SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second), - swig::ConstIterator::descriptor(),SWIG_POINTER_OWN); - RARRAY_LEN($result) = 2; + rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).first), + swig::ConstIterator::descriptor(),SWIG_POINTER_OWN)); + rb_ary_push($result, SWIG_NewPointerObj(swig::make_const_iterator(%static_cast($1,const $type &).second), + swig::ConstIterator::descriptor(),SWIG_POINTER_OWN)); } @@ -1089,9 +1087,8 @@ namespace swig { int i = 0; for (const_iterator it = seq.begin(); it != seq.end(); ++it, ++i) { - RARRAY_PTR(obj)[i] = swig::from< value_type >(*it); + rb_ary_push(obj, swig::from< value_type >(*it)); } - RARRAY_LEN(obj) = size; rb_obj_freeze(obj); // treat as immutable result return obj; } else { diff --git a/Lib/ruby/std_pair.i b/Lib/ruby/std_pair.i index cb714e4a8..f81cf7737 100644 --- a/Lib/ruby/std_pair.i +++ b/Lib/ruby/std_pair.i @@ -118,13 +118,11 @@ static VALUE from(const std::pair& val) { VALUE obj = rb_ary_new2(2); - RARRAY_PTR(obj)[0] = swig::from< - typename swig::noconst_traits::noconst_type>(val.first); - RARRAY_PTR(obj)[1] = swig::from(val.second); - RARRAY_LEN(obj) = 2; - rb_define_singleton_method(obj, "second", + rb_ary_push(obj, swig::from::noconst_type>(val.first)); + rb_ary_push(obj, swig::from(val.second)); + rb_define_singleton_method(obj, "second", VALUEFUNC(_wrap_pair_second), 0 ); - rb_define_singleton_method(obj, "second=", + rb_define_singleton_method(obj, "second=", VALUEFUNC(_wrap_pair_second_eq), 1 ); rb_obj_freeze(obj); // treat as immutable tuple return obj; diff --git a/Lib/ruby/std_set.i b/Lib/ruby/std_set.i index 64428abf6..09c4404cf 100644 --- a/Lib/ruby/std_set.i +++ b/Lib/ruby/std_set.i @@ -170,10 +170,9 @@ %typemap(out,noblock=1,fragment="RubyPairBoolOutputIterator") std::pair { $result = rb_ary_new2(2); - RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,$type &).first), - swig::Iterator::descriptor(),SWIG_POINTER_OWN); - RARRAY_PTR($result)[1] = SWIG_From(bool)(%static_cast($1,const $type &).second); - RARRAY_LEN($result) = 2; + rb_ary_push($result, SWIG_NewPointerObj(swig::make_set_nonconst_iterator(%static_cast($1,$type &).first), + swig::Iterator::descriptor(),SWIG_POINTER_OWN)); + rb_ary_push($result, SWIG_From(bool)(%static_cast($1,const $type &).second)); } %extend { From 1712fb7e4486869c59cf74335193f5dcda4656cf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Feb 2010 15:37:53 +0000 Subject: [PATCH 343/352] Add in some testcases that should have been checked in a while ago git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11860 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/global_scope_types.i | 44 ++++++++++++++++++++++++ Examples/test-suite/typemap_template.i | 34 ++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 Examples/test-suite/global_scope_types.i create mode 100644 Examples/test-suite/typemap_template.i diff --git a/Examples/test-suite/global_scope_types.i b/Examples/test-suite/global_scope_types.i new file mode 100644 index 000000000..d5bd7ad23 --- /dev/null +++ b/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 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&) {} + }; + +} + +void funcptrtest( void (*)(::Dingaling) ) {} +%} + diff --git a/Examples/test-suite/typemap_template.i b/Examples/test-suite/typemap_template.i new file mode 100644 index 000000000..ad35371cc --- /dev/null +++ b/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 *)0; /* in typemap generic for $type */} +%typemap(in) const TemplateTest1< ZZ > & {$1 = (TemplateTest1 *)0; /* in typemap ZZ for $type */} +%typemap(in) const TemplateTest1< int > & {$1 = (TemplateTest1 *)0; /* in typemap int for $type */} + +%inline %{ +template struct TemplateTest1 { + void setT(const TemplateTest1& t) {} +}; +%} + +%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) + {} +%} + From 00880434ef2eaf16f72c8de087a5dcc13d9f4c47 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Feb 2010 15:54:28 +0000 Subject: [PATCH 344/352] minor change for compiler ref warning git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11861 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/global_scope_types.i | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/global_scope_types.i b/Examples/test-suite/global_scope_types.i index d5bd7ad23..4c73dfa72 100644 --- a/Examples/test-suite/global_scope_types.i +++ b/Examples/test-suite/global_scope_types.i @@ -32,7 +32,7 @@ namespace Spac { class Test { public: void something(::Dingaling t, ::Dingaling* pt, ::Dingaling& rt, const ::Dingaling& crt) {} - void tsomething(MyTemplate< ::Dingaling > t1, MyTemplate< const ::Dingaling& > t2) {} + 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&) {} }; From 830de4d2f19335bd2595e48f318029067d3fd8e7 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Feb 2010 16:59:41 +0000 Subject: [PATCH 345/352] Various ruby-1.9.x compile fixes including patch from Nibble git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11862 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/ruby/rubycontainer.swg | 11 ++++++----- Lib/ruby/rubycontainer_extended.swg | 2 +- Lib/ruby/rubyrun.swg | 2 +- Lib/ruby/std_map.i | 3 ++- Lib/ruby/std_multimap.i | 3 ++- Lib/ruby/std_pair.i | 3 ++- 7 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 7c47470fa..d40ed79d5 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,9 @@ Version 1.3.41 (in progress) ============================ +2010-02-13: wsfulton + [Ruby] A few fixes for compiling under ruby-1.9.x including patch from 'Nibble'. + 2010-02-13: wsfulton [Ruby] Apply patch from Patrick Bennett to fix RARRAY_LEN and RARRAY_PTR usage for Ruby 1.9.x used in various STL wrappers. diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index 8008654c6..60c128456 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -564,7 +564,8 @@ namespace swig { Sequence::const_iterator i = $self->begin(); Sequence::const_iterator e = $self->end(); - VALUE str = rb_str_new2( swig::type_name< Sequence >() ); + const char *type_name = swig::type_name< Sequence >(); + VALUE str = rb_str_new2(type_name); str = rb_str_cat2( str, " [" ); bool comma = false; VALUE tmp; @@ -928,7 +929,7 @@ namespace swig } catch( std::invalid_argument ) { - rb_raise( rb_eArgError, + rb_raise( rb_eArgError, "%s", Ruby_Format_TypeError( "", swig::type_name(), __FUNCTION__, idx+2, elem )); @@ -955,7 +956,7 @@ namespace swig } catch( std::invalid_argument ) { - rb_raise( rb_eArgError, + rb_raise( rb_eArgError, "%s", Ruby_Format_TypeError( "", swig::type_name(), __FUNCTION__, idx+2, elem )); @@ -1010,7 +1011,7 @@ namespace swig { if (seq) { VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { - rb_raise(rb_eTypeError, e.what()); + rb_raise(rb_eTypeError, "%s", e.what()); } } return SWIG_ERROR; @@ -1050,7 +1051,7 @@ namespace swig { if (seq) { VALUE lastErr = rb_gv_get("$!"); if (lastErr == Qnil) { - rb_raise(rb_eTypeError, e.what()); + rb_raise(rb_eTypeError, "%s", e.what()); } } return SWIG_ERROR; diff --git a/Lib/ruby/rubycontainer_extended.swg b/Lib/ruby/rubycontainer_extended.swg index 360e399ce..81936b9da 100644 --- a/Lib/ruby/rubycontainer_extended.swg +++ b/Lib/ruby/rubycontainer_extended.swg @@ -76,7 +76,7 @@ catch ( const std::invalid_argument& ) { rb_raise(rb_eTypeError, - "Yield block did not return a valid element for " #Container); + "Yield block did not return a valid element for " "Container"); } return $self; diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index 177e395d0..5aa43b6cf 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -100,7 +100,7 @@ static ID swig_call_id = 0; ++swig_virtual_calls; # define SWIG_RELEASE_STACK --swig_virtual_calls; # define Ruby_DirectorTypeMismatchException(x) \ - rb_raise( rb_eTypeError, x ); return c_result; + rb_raise( rb_eTypeError, "%s", x ); return c_result; static unsigned int swig_virtual_calls = 0; diff --git a/Lib/ruby/std_map.i b/Lib/ruby/std_map.i index cc22fef51..e23f1c31b 100644 --- a/Lib/ruby/std_map.i +++ b/Lib/ruby/std_map.i @@ -345,7 +345,8 @@ { Map::const_iterator i = $self->begin(); Map::const_iterator e = $self->end(); - VALUE str = rb_str_new2( swig::type_name< Map >() ); + const char *type_name = swig::type_name< Map >(); + VALUE str = rb_str_new2( type_name ); str = rb_str_cat2( str, " {" ); bool comma = false; VALUE tmp; diff --git a/Lib/ruby/std_multimap.i b/Lib/ruby/std_multimap.i index 7fec50de1..31795c768 100644 --- a/Lib/ruby/std_multimap.i +++ b/Lib/ruby/std_multimap.i @@ -115,7 +115,8 @@ { MultiMap::iterator i = $self->begin(); MultiMap::iterator e = $self->end(); - VALUE str = rb_str_new2( swig::type_name< MultiMap >() ); + const char *type_name = swig::type_name< MultiMap >(); + VALUE str = rb_str_new2( type_name ); str = rb_str_cat2( str, " {" ); VALUE tmp; while ( i != e ) diff --git a/Lib/ruby/std_pair.i b/Lib/ruby/std_pair.i index f81cf7737..5b4c8baf2 100644 --- a/Lib/ruby/std_pair.i +++ b/Lib/ruby/std_pair.i @@ -146,7 +146,8 @@ VALUE inspect() const { VALUE tmp; - VALUE str = rb_str_new2( swig::type_name< pair >() ); + const char *type_name = swig::type_name< pair >(); + VALUE str = rb_str_new2( type_name ); str = rb_str_cat2( str, " (" ); tmp = swig::from( $self->first ); tmp = rb_obj_as_string( tmp ); From d64d31a5fa4253b5cc815816a40961b6a0278727 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 13 Feb 2010 17:12:15 +0000 Subject: [PATCH 346/352] Compile fixes for ruby-1.9.x git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11863 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/ruby/multimap/example.i | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/ruby/multimap/example.i b/Examples/ruby/multimap/example.i index 56952ec9e..f68422a18 100644 --- a/Examples/ruby/multimap/example.i +++ b/Examples/ruby/multimap/example.i @@ -20,7 +20,7 @@ extern int gcd(int x, int y); if (TYPE($input) != T_ARRAY) { SWIG_exception(SWIG_ValueError, "Expected an array"); } - $1 = RARRAY($input)->len; + $1 = RARRAY_LEN($input); if ($1 == 0) { SWIG_exception(SWIG_ValueError, "List must contain at least 1 element"); } @@ -47,7 +47,7 @@ extern int gcdmain(int argc, char *argv[]); SWIG_exception(SWIG_ValueError, "Expected a string"); } $1 = STR2CSTR($input); - $2 = RSTRING($input)->len; + $2 = RSTRING_LEN($input); } extern int count(char *bytes, int len, char c); @@ -61,7 +61,7 @@ extern int count(char *bytes, int len, char c); SWIG_exception(SWIG_ValueError,"Expected a string"); } temp = STR2CSTR($input); - $2 = RSTRING($input)->len; + $2 = RSTRING_LEN($input); $1 = (char *) malloc($2+1); memmove($1,temp,$2); } From b966af251b799a8910398cda78ab4ccb48a69c14 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 23 Feb 2010 07:00:34 +0000 Subject: [PATCH 347/352] Variable name change to remove confusion in preparation for a future commit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11866 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/Modules/tcl8.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index ef6b3109e..54648c2b0 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -28,7 +28,7 @@ static String *methods_tab = 0; /* Methods table */ static String *attr_tab = 0; /* Attribute table */ static String *prefix = 0; static String *module = 0; -static int nspace = 0; +static int namespace_option = 0; static String *init_name = 0; static String *ns_name = 0; static int have_constructor; @@ -97,7 +97,7 @@ public: i++; } } else if (strcmp(argv[i], "-namespace") == 0) { - nspace = 1; + namespace_option = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-itcl") == 0) { itcl = 1; @@ -204,7 +204,7 @@ public: Printf(f_header, "#define SWIG_init %s\n", init_name); Printf(f_header, "#define SWIG_name \"%s\"\n", module); - if (nspace) { + if (namespace_option) { Printf(f_header, "#define SWIG_prefix \"%s::\"\n", ns_name); Printf(f_header, "#define SWIG_namespace \"%s\"\n\n", ns_name); } else { @@ -666,7 +666,7 @@ public: virtual int constantWrapper(Node *n) { String *name = Getattr(n, "name"); String *iname = Getattr(n, "sym:name"); - String *nsname = !nspace ? Copy(iname) : NewStringf("%s::%s", ns_name, iname); + String *nsname = !namespace_option ? Copy(iname) : NewStringf("%s::%s", ns_name, iname); SwigType *type = Getattr(n, "type"); String *rawval = Getattr(n, "rawval"); String *value = rawval ? rawval : Getattr(n, "value"); @@ -674,7 +674,7 @@ public: if (!addSymbol(iname, n)) return SWIG_ERROR; - if (nspace) + if (namespace_option) Setattr(n, "sym:name", nsname); /* Special hook for member pointer */ @@ -865,7 +865,7 @@ public: Printv(ptrclass, attributes, NIL); // base class swig_getset was being called for complex inheritance trees - if (nspace) { + if (namespace_option) { Printv(ptrclass, " protected method ", class_name, "_swig_getset {var name1 name2 op} {\n", NIL); @@ -1018,7 +1018,7 @@ public: if (Len(dv) > 0) { String *defval = NewString(dv); - if (nspace) { + if (namespace_option) { Insert(defval, 0, "::"); Insert(defval, 0, ns_name); } @@ -1036,7 +1036,7 @@ public: } Printv(imethods, "] ", NIL); - if (nspace) { + if (namespace_option) { Printv(imethods, "{ ", ns_name, "::", class_name, "_", realname, " $swigobj", NIL); } else { Printv(imethods, "{ ", class_name, "_", realname, " $swigobj", NIL); @@ -1164,7 +1164,7 @@ public: // Call to constructor wrapper and parent Ptr class // [BRE] add -namespace/-prefix support - if (nspace) { + if (namespace_option) { Printv(constructor, " ", realname, "Ptr::constructor [", ns_name, "::new_", realname, NIL); } else { Printv(constructor, " ", realname, "Ptr::constructor [new_", realname, NIL); @@ -1231,7 +1231,7 @@ public: if (!temp) temp = NewString(""); Clear(temp); - if (nspace) { + if (namespace_option) { Printf(temp, "%s::%s ", ns_name, iname); } else { Printf(temp, "%s ", iname); From f6ce153f8f8f1570df5a3a6f961b7e0a3f30dbea Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 27 Feb 2010 15:53:21 +0000 Subject: [PATCH 348/352] Remove -dirvtable from the optimizations included by -O as it this option currently leads to memory leaks git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11872 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++++ Source/Modules/python.cxx | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index d40ed79d5..902308847 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,6 +1,10 @@ Version 1.3.41 (in progress) ============================ +2010-02-27: wsfulton + [Python] Remove -dirvtable from the optimizations included by -O as it this option + currently leads to memory leaks as reported by Johan Blake. + 2010-02-13: wsfulton [Ruby] A few fixes for compiling under ruby-1.9.x including patch from 'Nibble'. diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index bc76f17d4..3c7e3de7a 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -143,8 +143,8 @@ static const char *usage3 = (char *) "\ -proxydel - Generate a __del__ method even though it is now redundant (default) \n\ -safecstrings - Use safer (but slower) C string mapping, generating copies from Python -> C/C++\n\ -threads - Add thread support for all the interface\n\ - -O - Enable all the optimization options: \n\ - -modern -fastdispatch -dirvtable -nosafecstrings -fvirtual -noproxydel \n\ + -O - Enable the following optimization options: \n\ + -modern -fastdispatch -nosafecstrings -fvirtual -noproxydel \n\ -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone \n\ -py3 - Generate code with Python 3 specific features:\n\ Function annotation \n\ @@ -405,7 +405,6 @@ public: } else if (strcmp(argv[i], "-O") == 0) { classic = 0; modern = 1; - dirvtable = 1; safecstrings = 0; buildnone = 0; nobuildnone = 1; From 283bb830bd1f9eb87ae2d957d4095c5de47a0bf9 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 27 Feb 2010 23:04:21 +0000 Subject: [PATCH 349/352] SWIG license change - Licenses put in place and bump version to 2.0.0 - Source moves to GPLv3. The Examples and Lib move to a very permissive license, removing the BSD license restrictions as agreed by committers since it was inadvertently introduced. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11873 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 10 +- COPYRIGHT | 63 ++++ Doc/Manual/Sections.html | 2 +- LICENSE | 109 ++----- LICENSE-GPL | 674 +++++++++++++++++++++++++++++++++++++++ LICENSE-UNIVERSITIES | 95 ++++++ README | 58 +--- configure.in | 2 +- 8 files changed, 858 insertions(+), 155 deletions(-) create mode 100644 COPYRIGHT create mode 100644 LICENSE-GPL create mode 100644 LICENSE-UNIVERSITIES diff --git a/ANNOUNCE b/ANNOUNCE index 770df1b20..2595f7a55 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,10 +1,10 @@ -*** ANNOUNCE: SWIG 1.3.41 (in progress) *** +*** ANNOUNCE: SWIG 2.0.0 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-1.3.41, the latest installment in the -SWIG development effort. SWIG-1.3.41 includes a number of bug fixes +We're pleased to announce SWIG-2.0.0, the latest installment in the +SWIG development effort. SWIG-2.0.0 includes a number of bug fixes and enhancements. What is SWIG? @@ -24,11 +24,11 @@ Availability: ------------- The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-1.3.41.tar.gz + http://prdownloads.sourceforge.net/swig/swig-2.0.0.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-1.3.41.zip + http://prdownloads.sourceforge.net/swig/swigwin-2.0.0.zip Please report problems with this release to the swig-dev mailing list, details at http://www.swig.org/mail.html. diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 000000000..45f9d6b45 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,63 @@ +SWIG Copyright and Authors +-------------------------- + +Copyright (c) 1995-2010 The SWIG Developers +Copyright (c) 2005-2006 Arizona Board of Regents (University of Arizona). +Copyright (c) 1998-2005 University of Chicago. +Copyright (c) 1995-1998 The University of Utah and the Regents of the University of California + +Portions also copyrighted by: + Network Applied Communication Laboratory, Inc + Information-technology Promotion Agency, Japan + +Active SWIG Developers: + William Fulton (wsf@fultondesigns.co.uk) (SWIG core, Java, C#, Windows, Cygwin) + Olly Betts (olly@survex.com) (PHP) + Joseph Wang (joequant@gmail.com) (R) + Xavier Delacour (xavier.delacour@gmail.com) (Octave) + +Past SWIG developers and major contributors include: + Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl) + Henning Thielemann (swig@henning-thielemann.de) (Modula3) + Matthias Köppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile, MzScheme) + Luigi Ballabio (luigi.ballabio@fastwebnet.it) (STL wrapping) + Mikel Bancroft (mikel@franz.com) (Allegro CL) + Surendra Singhi (efuzzyone@netscape.net) (CLISP, CFFI) + Marcelo Matus (mmatus@acms.arizona.edu) (SWIG core, Python, UTL[python,perl,tcl,ruby]) + Art Yerkes (ayerkes@speakeasy.net) (Ocaml) + Lyle Johnson (lyle@users.sourceforge.net) (Ruby) + Charlie Savage (cfis@interserv.com) (Ruby) + Thien-Thi Nguyen (ttn@glug.org) (build/test/misc) + Richard Palmer (richard@magicality.org) (PHP) + Sam Liddicott - Anonova Ltd (saml@liddicott.com) (PHP) + Tim Hockin - Sun Microsystems (thockin@sun.com) (PHP) + Kevin Ruland (PHP) + Shibukawa Yoshiki (Japanese Translation) + Jason Stewart (jason@openinformatics.com) (Perl5) + Loic Dachary (Perl5) + David Fletcher (Perl5) + Gary Holt (Perl5) + Masaki Fukushima (Ruby) + Scott Michel (scottm@cs.ucla.edu) (Java directors) + Tiger Feng (songyanf@cs.uchicago.edu) (SWIG core) + Mark Rose (mrose@stm.lbl.gov) (Directors) + Jonah Beckford (beckford@usermail.com) (CHICKEN) + Ahmon Dancy (dancy@franz.com) (Allegro CL) + Dirk Gerrits (Allegro CL) + Neil Cawse (C#) + Harco de Hilster (Java) + Alexey Dyachenko (dyachenko@fromru.com) (Tcl) + Bob Techentin (Tcl) + Martin Froehlich (Guile) + Marcio Luis Teixeira (Guile) + Duncan Temple Lang (R) + Miklos Vajna (PHP directors) + Mark Gossage (mark@gossage.cjb.net) (Lua) + Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL) + John Lenz (Guile, MzScheme updates, Chicken module, runtime system) + +Past contributors include: + James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran + Kovuk, Oleg Tolmatcev, Tal Shalif, Lluis Padro, Chris Seatory, Igor Bely, Robin Dunn + (See CHANGES and CHANGES.current for a more complete list). + diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index b98661c0d..ab47ed8ee 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

      SWIG-1.3 Development Documentation

      -Last update : SWIG-1.3.41 (in progress) +Last update : SWIG-2.0.0 (in progress)

      Sections

      diff --git a/LICENSE b/LICENSE index fdb73d916..d7a422fda 100644 --- a/LICENSE +++ b/LICENSE @@ -1,95 +1,22 @@ -SWIG is distributed under the following terms: +SWIG is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. See the LICENSE-GPL file for +the full terms of the GNU General Public license version 3. -I. +Portions of SWIG are also licensed under the terms of the licenses +in the file LICENSE-UNIVERSITIES. You must observe the terms of +these licenses, as well as the terms of the GNU General Public License, +when you distribute SWIG. -Copyright (c) 1995-1998 -The University of Utah and the Regents of the University of California -All Rights Reserved +The SWIG library and examples, under the Lib and Examples top level +directories, are distributed under the following terms: -Permission is hereby granted, without written agreement and without -license or royalty fees, to use, copy, modify, and distribute this -software and its documentation for any purpose, provided that -(1) The above copyright notice and the following two paragraphs -appear in all copies of the source code and (2) redistributions -including binaries reproduces these notices in the supporting -documentation. Substantial modifications to this software may be -copyrighted by their authors and need not follow the licensing terms -described here, provided that the new terms are clearly indicated in -all files where they apply. - -IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE -UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY -PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, -EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF -THE POSSIBILITY OF SUCH DAMAGE. - -THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH -SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND -THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, -SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - - -II. - -This software includes contributions that are Copyright (c) 1998-2005 -University of Chicago. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. Redistributions -in binary form must reproduce the above copyright notice, this list of -conditions and the following disclaimer in the documentation and/or -other materials provided with the distribution. Neither the name of -the University of Chicago nor the names of its contributors may be -used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF CHICAGO AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF -CHICAGO OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -III. - -This software includes contributions that are Copyright (c) 2005-2006 -Arizona Board of Regents (University of Arizona). -All Rights Reserved - -Permission is hereby granted, without written agreement and without -license or royalty fees, to use, copy, modify, and distribute this -software and its documentation for any purpose, provided that -(1) The above copyright notice and the following two paragraphs -appear in all copies of the source code and (2) redistributions -including binaries reproduces these notices in the supporting -documentation. Substantial modifications to this software may be -copyrighted by their authors and need not follow the licensing terms -described here, provided that the new terms are clearly indicated in -all files where they apply. - -THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF ARIZONA AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF -ARIZONA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + You may copy, modify, distribute, and make derivative works based on + this software, in source code or object code form, without + restriction. If you distribute the software to others, you may do + so according to the terms of your choice. This software is offered as + is, without warranty of any kind. +See the COPYRIGHT file for a list of contributors to SWIG and their +copyright notices. diff --git a/LICENSE-GPL b/LICENSE-GPL new file mode 100644 index 000000000..94a9ed024 --- /dev/null +++ b/LICENSE-GPL @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/LICENSE-UNIVERSITIES b/LICENSE-UNIVERSITIES new file mode 100644 index 000000000..fdb73d916 --- /dev/null +++ b/LICENSE-UNIVERSITIES @@ -0,0 +1,95 @@ +SWIG is distributed under the following terms: + +I. + +Copyright (c) 1995-1998 +The University of Utah and the Regents of the University of California +All Rights Reserved + +Permission is hereby granted, without written agreement and without +license or royalty fees, to use, copy, modify, and distribute this +software and its documentation for any purpose, provided that +(1) The above copyright notice and the following two paragraphs +appear in all copies of the source code and (2) redistributions +including binaries reproduces these notices in the supporting +documentation. Substantial modifications to this software may be +copyrighted by their authors and need not follow the licensing terms +described here, provided that the new terms are clearly indicated in +all files where they apply. + +IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE +UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY +PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, +EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. + +THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH +SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND +THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, +SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + + +II. + +This software includes contributions that are Copyright (c) 1998-2005 +University of Chicago. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. Redistributions +in binary form must reproduce the above copyright notice, this list of +conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. Neither the name of +the University of Chicago nor the names of its contributors may be +used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF CHICAGO AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF +CHICAGO OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +III. + +This software includes contributions that are Copyright (c) 2005-2006 +Arizona Board of Regents (University of Arizona). +All Rights Reserved + +Permission is hereby granted, without written agreement and without +license or royalty fees, to use, copy, modify, and distribute this +software and its documentation for any purpose, provided that +(1) The above copyright notice and the following two paragraphs +appear in all copies of the source code and (2) redistributions +including binaries reproduces these notices in the supporting +documentation. Substantial modifications to this software may be +copyrighted by their authors and need not follow the licensing terms +described here, provided that the new terms are clearly indicated in +all files where they apply. + +THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF ARIZONA AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF +ARIZONA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + diff --git a/README b/README index 2101925fe..8cdc34887 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.41 (in progress) +Version: 2.0.0 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, @@ -13,62 +13,6 @@ the listed languages, or to extend C/C++ programs with a scripting language. This distribution represents the latest development release of SWIG. -The guilty parties working on this are: - -Active Developers: - William Fulton (wsf@fultondesigns.co.uk) (SWIG core, Java, C#, Windows, Cygwin) - Olly Betts (olly@survex.com) (PHP) - John Lenz (Guile, MzScheme updates, Chicken module, runtime system) - Mark Gossage (mark@gossage.cjb.net) (Lua) - Joseph Wang (joequant@gmail.com) (R) - Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL) - Xavier Delacour (xavier.delacour@gmail.com) (Octave) - -Major contributors include: - Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl) - Henning Thielemann (swig@henning-thielemann.de) (Modula3) - Matthias Köppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile, MzScheme) - Luigi Ballabio (luigi.ballabio@fastwebnet.it) (STL wrapping) - Mikel Bancroft (mikel@franz.com) (Allegro CL) - Surendra Singhi (efuzzyone@netscape.net) (CLISP, CFFI) - Marcelo Matus (mmatus@acms.arizona.edu) (SWIG core, Python, UTL[python,perl,tcl,ruby]) - Art Yerkes (ayerkes@speakeasy.net) (Ocaml) - Lyle Johnson (lyle@users.sourceforge.net) (Ruby) - Charlie Savage (cfis@interserv.com) (Ruby) - Thien-Thi Nguyen (ttn@glug.org) (build/test/misc) - Richard Palmer (richard@magicality.org) (PHP) - Sam Liddicott - Anonova Ltd (saml@liddicott.com) (PHP) - Tim Hockin - Sun Microsystems (thockin@sun.com) (PHP) - Kevin Ruland (PHP) - Shibukawa Yoshiki (Japanese Translation) - Jason Stewart (jason@openinformatics.com) (Perl5) - Loic Dachary (Perl5) - David Fletcher (Perl5) - Gary Holt (Perl5) - Masaki Fukushima (Ruby) - Scott Michel (scottm@cs.ucla.edu) (Java directors) - Tiger Feng (songyanf@cs.uchicago.edu) (SWIG core) - Mark Rose (mrose@stm.lbl.gov) (Directors) - Jonah Beckford (beckford@usermail.com) (CHICKEN) - Ahmon Dancy (dancy@franz.com) (Allegro CL) - Dirk Gerrits (Allegro CL) - Neil Cawse (C#) - Harco de Hilster (Java) - Alexey Dyachenko (dyachenko@fromru.com) (Tcl) - Bob Techentin (Tcl) - Martin Froehlich (Guile) - Marcio Luis Teixeira (Guile) - Duncan Temple Lang (R) - Miklos Vajna (PHP directors) - -Past contributors include: - James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran - Kovuk, Oleg Tolmatcev, Tal Shalif, Lluis Padro, Chris Seatory, Igor Bely, Robin Dunn - (See CHANGES and CHANGES.current for a more complete list). - -Portions also copyrighted by companies/corporations; - Network Applied Communication Laboratory, Inc - Information-technology Promotion Agency, Japan Up-to-date SWIG related information can be found at diff --git a/configure.in b/configure.in index f457d73e3..b2403c41b 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. dnl The macros which aren't shipped with the autotools are stored in the dnl Tools/config directory in .m4 files. -AC_INIT([swig],[1.3.41],[http://www.swig.org]) +AC_INIT([swig],[2.0.0],[http://www.swig.org]) AC_PREREQ(2.58) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) AC_CONFIG_AUX_DIR([Tools/config]) From 4308dd03cfd1356c41830860824063a429db0fd5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 27 Feb 2010 23:26:02 +0000 Subject: [PATCH 350/352] SWIG license change - The Examples and Lib move to a very permissive license in the LICENSE file, removing the BSD license restrictions as agreed by committers since it was inadvertently introduced. Remove some examples where the impact of the license change is not clear. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11874 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/GIFPlot/Chicken/check.list | 3 - Examples/GIFPlot/Chicken/full/Makefile | 28 - Examples/GIFPlot/Chicken/full/README | 6 - Examples/GIFPlot/Chicken/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Chicken/full/gifplot.i | 26 - .../GIFPlot/Chicken/full/test-gifplot.scm | 66 - Examples/GIFPlot/Chicken/simple/Makefile | 28 - Examples/GIFPlot/Chicken/simple/README | 5 - Examples/GIFPlot/Chicken/simple/simple.i | 34 - .../GIFPlot/Chicken/simple/test-simple.scm | 29 - Examples/GIFPlot/Common-Lisp/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Common-Lisp/full/gifplot.i | 21 - Examples/GIFPlot/Common-Lisp/full/runme.lisp | 59 - Examples/GIFPlot/Guile/check.list | 3 - Examples/GIFPlot/Guile/full/Makefile | 28 - Examples/GIFPlot/Guile/full/README | 8 - Examples/GIFPlot/Guile/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Guile/full/gifplot.i | 21 - Examples/GIFPlot/Guile/full/runme.scm | 66 - Examples/GIFPlot/Guile/simple/Makefile | 28 - Examples/GIFPlot/Guile/simple/README | 11 - Examples/GIFPlot/Guile/simple/runme.scm | 30 - Examples/GIFPlot/Guile/simple/simple.i | 34 - Examples/GIFPlot/Include/gifplot.h | 333 --- Examples/GIFPlot/Interface/gifplot.i | 264 -- Examples/GIFPlot/Java/check.list | 4 - Examples/GIFPlot/Java/full/Makefile | 20 - Examples/GIFPlot/Java/full/README | 8 - Examples/GIFPlot/Java/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Java/full/gifplot.i | 15 - Examples/GIFPlot/Java/full/runme.java | 75 - Examples/GIFPlot/Java/shadow/Makefile | 21 - Examples/GIFPlot/Java/shadow/README | 5 - Examples/GIFPlot/Java/shadow/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Java/shadow/runme.java | 76 - Examples/GIFPlot/Java/simple/Makefile | 21 - Examples/GIFPlot/Java/simple/README | 5 - Examples/GIFPlot/Java/simple/runme.java | 41 - Examples/GIFPlot/Java/simple/simple.i | 38 - Examples/GIFPlot/Lib/Makefile.in | 22 - Examples/GIFPlot/Lib/color.c | 143 -- Examples/GIFPlot/Lib/font.c | 705 ------ Examples/GIFPlot/Lib/frame.c | 924 ------- Examples/GIFPlot/Lib/gif.c | 672 ----- Examples/GIFPlot/Lib/matrix.c | 343 --- Examples/GIFPlot/Lib/pixmap.c | 159 -- Examples/GIFPlot/Lib/plot2d.c | 445 ---- Examples/GIFPlot/Lib/plot3d.c | 2181 ----------------- Examples/GIFPlot/Makefile.in | 23 - Examples/GIFPlot/Ocaml/check.list | 3 - Examples/GIFPlot/Ocaml/full/Makefile | 33 - Examples/GIFPlot/Ocaml/full/README | 8 - Examples/GIFPlot/Ocaml/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Ocaml/full/gifplot.i | 15 - Examples/GIFPlot/Ocaml/full/runme.ml | 87 - Examples/GIFPlot/Ocaml/simple/Makefile | 33 - Examples/GIFPlot/Ocaml/simple/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Ocaml/simple/runme.ml | 35 - Examples/GIFPlot/Ocaml/simple/simple.i | 33 - Examples/GIFPlot/Perl5/check.list | 4 - Examples/GIFPlot/Perl5/full/Makefile | 24 - Examples/GIFPlot/Perl5/full/README | 8 - Examples/GIFPlot/Perl5/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Perl5/full/gifplot.i | 15 - Examples/GIFPlot/Perl5/full/runme.pl | 68 - Examples/GIFPlot/Perl5/shadow/Makefile | 25 - Examples/GIFPlot/Perl5/shadow/README | 2 - Examples/GIFPlot/Perl5/shadow/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Perl5/shadow/runme.pl | 68 - Examples/GIFPlot/Perl5/simple/Makefile | 24 - Examples/GIFPlot/Perl5/simple/README | 5 - Examples/GIFPlot/Perl5/simple/runme.pl | 28 - Examples/GIFPlot/Perl5/simple/simple.i | 38 - Examples/GIFPlot/Php/check.list | 3 - Examples/GIFPlot/Php/full/Makefile | 20 - Examples/GIFPlot/Php/full/README | 4 - Examples/GIFPlot/Php/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Php/full/gifplot.i | 15 - Examples/GIFPlot/Php/full/runme.php | 78 - Examples/GIFPlot/Php/shadow/Makefile | 19 - Examples/GIFPlot/Php/shadow/README | 2 - Examples/GIFPlot/Php/shadow/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Php/shadow/runme.php | 79 - Examples/GIFPlot/Php/simple/Makefile | 20 - Examples/GIFPlot/Php/simple/README | 5 - Examples/GIFPlot/Php/simple/runme.php | 32 - Examples/GIFPlot/Php/simple/simple.i | 38 - Examples/GIFPlot/Pike/check.list | 2 - Examples/GIFPlot/Pike/simple/Makefile | 24 - Examples/GIFPlot/Pike/simple/README | 5 - Examples/GIFPlot/Pike/simple/runme.pike | 30 - Examples/GIFPlot/Pike/simple/simple.i | 38 - Examples/GIFPlot/Python/check.list | 4 - Examples/GIFPlot/Python/full/Makefile | 26 - Examples/GIFPlot/Python/full/README | 8 - Examples/GIFPlot/Python/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Python/full/gifplot.i | 15 - Examples/GIFPlot/Python/full/runme.py | 64 - Examples/GIFPlot/Python/shadow/Makefile | 27 - Examples/GIFPlot/Python/shadow/README | 8 - Examples/GIFPlot/Python/shadow/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Python/shadow/runme.py | 62 - Examples/GIFPlot/Python/simple/Makefile | 26 - Examples/GIFPlot/Python/simple/README | 5 - Examples/GIFPlot/Python/simple/runme.py | 27 - Examples/GIFPlot/Python/simple/simple.i | 38 - Examples/GIFPlot/README | 59 - Examples/GIFPlot/Ruby/check.list | 4 - Examples/GIFPlot/Ruby/full/Makefile | 24 - Examples/GIFPlot/Ruby/full/README | 8 - Examples/GIFPlot/Ruby/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Ruby/full/gifplot.i | 15 - Examples/GIFPlot/Ruby/full/runme.rb | 66 - Examples/GIFPlot/Ruby/shadow/Makefile | 25 - Examples/GIFPlot/Ruby/shadow/README | 5 - Examples/GIFPlot/Ruby/shadow/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Ruby/shadow/runme.rb | 66 - Examples/GIFPlot/Ruby/simple/Makefile | 24 - Examples/GIFPlot/Ruby/simple/README | 5 - Examples/GIFPlot/Ruby/simple/runme.rb | 27 - Examples/GIFPlot/Ruby/simple/simple.i | 38 - Examples/GIFPlot/Tcl/check.list | 4 - Examples/GIFPlot/Tcl/full/Makefile | 24 - Examples/GIFPlot/Tcl/full/README | 8 - Examples/GIFPlot/Tcl/full/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Tcl/full/gifplot.i | 15 - Examples/GIFPlot/Tcl/full/runme.tcl | 67 - Examples/GIFPlot/Tcl/mandel/Makefile | 24 - Examples/GIFPlot/Tcl/mandel/README | 6 - Examples/GIFPlot/Tcl/mandel/cmap | Bin 768 -> 0 bytes Examples/GIFPlot/Tcl/mandel/display.tcl | 68 - Examples/GIFPlot/Tcl/mandel/mandel.i | 47 - Examples/GIFPlot/Tcl/mandel/mandel.tcl | 170 -- Examples/GIFPlot/Tcl/simple/Makefile | 24 - Examples/GIFPlot/Tcl/simple/README | 5 - Examples/GIFPlot/Tcl/simple/runme.tcl | 27 - Examples/GIFPlot/Tcl/simple/simple.i | 38 - Examples/chicken/zlib/Makefile | 28 - Examples/chicken/zlib/README.html | 1666 ------------- Examples/chicken/zlib/example.i | 76 - Examples/chicken/zlib/test-zlib.scm | 41 - Examples/guile/check.list | 1 - Examples/lua/lua.c | 1 - .../test-suite/csharp/li_std_map_runme.cs | 5 - Examples/test-suite/li_std_queue.i | 11 +- Examples/test-suite/li_std_set.i | 22 +- Examples/test-suite/li_std_stack.i | 11 +- .../ruby/ruby_li_std_speed_runme.rb | 3 - Examples/test-suite/ruby_li_std_speed.i | 11 +- Examples/xml/example_gif.i | 329 --- Lib/allegrocl/allegrocl.swg | 2 - Lib/allegrocl/longlongs.i | 3 - Lib/allegrocl/std_list.i | 3 - Lib/allegrocl/std_string.i | 3 - Lib/attribute.i | 3 - Lib/carrays.i | 3 - Lib/cdata.i | 3 - Lib/chicken/chicken.swg | 3 - Lib/chicken/chickenrun.swg | 4 - Lib/chicken/multi-generic.scm | 2 +- Lib/chicken/std_string.i | 3 - Lib/chicken/typemaps.i | 3 - Lib/clisp/clisp.swg | 3 - Lib/cmalloc.i | 3 - Lib/constraints.i | 3 - Lib/cpointer.i | 3 - Lib/csharp/arrays_csharp.i | 3 - Lib/csharp/csharp.swg | 3 - Lib/csharp/csharphead.swg | 3 - Lib/csharp/director.swg | 3 - Lib/csharp/enums.swg | 3 - Lib/csharp/enumsimple.swg | 3 - Lib/csharp/enumtypesafe.swg | 3 - Lib/csharp/std_except.i | 3 - Lib/csharp/std_map.i | 3 - Lib/csharp/std_pair.i | 3 - Lib/csharp/std_string.i | 3 - Lib/csharp/std_vector.i | 3 - Lib/csharp/std_wstring.i | 3 - Lib/csharp/stl.i | 3 - Lib/csharp/typemaps.i | 3 - Lib/csharp/wchar.i | 3 - Lib/cstring.i | 3 - Lib/cwstring.i | 3 - Lib/exception.i | 3 - Lib/gcj/cni.swg | 3 - Lib/guile/common.scm | 6 - Lib/guile/cplusplus.i | 3 - Lib/guile/guile.i | 3 - Lib/guile/guile_gh.swg | 3 - Lib/guile/guile_gh_run.swg | 3 - Lib/guile/guile_scm.swg | 3 - Lib/guile/guile_scm_run.swg | 3 - Lib/guile/guilemain.i | 3 - Lib/guile/interpreter.i | 3 - Lib/guile/list-vector.i | 3 - Lib/guile/pointer-in-out.i | 3 - Lib/guile/ports.i | 3 - Lib/guile/std_common.i | 3 - Lib/guile/std_map.i | 3 - Lib/guile/std_pair.i | 3 - Lib/guile/std_string.i | 3 - Lib/guile/std_vector.i | 3 - Lib/guile/stl.i | 3 - Lib/guile/typemaps.i | 3 - Lib/inttypes.i | 3 - Lib/java/arrays_java.i | 3 - Lib/java/director.swg | 3 - Lib/java/enums.swg | 3 - Lib/java/enumsimple.swg | 3 - Lib/java/enumtypesafe.swg | 3 - Lib/java/enumtypeunsafe.swg | 3 - Lib/java/java.swg | 3 - Lib/java/javahead.swg | 3 - Lib/java/std_except.i | 3 - Lib/java/std_map.i | 3 - Lib/java/std_pair.i | 3 - Lib/java/std_string.i | 3 - Lib/java/std_vector.i | 3 - Lib/java/std_wstring.i | 3 - Lib/java/stl.i | 3 - Lib/java/typemaps.i | 3 - Lib/java/various.i | 3 - Lib/lua/_std_common.i | 3 - Lib/lua/lua.swg | 3 - Lib/lua/lua_fnptr.i | 3 - Lib/lua/luarun.swg | 3 - Lib/lua/luaruntime.swg | 3 - Lib/lua/luatypemaps.swg | 3 - Lib/lua/std_except.i | 3 - Lib/lua/std_map.i | 3 - Lib/lua/std_pair.i | 3 - Lib/lua/std_string.i | 3 - Lib/lua/std_vector.i | 3 - Lib/lua/stl.i | 3 - Lib/lua/typemaps.i | 3 - Lib/lua/wchar.i | 6 +- Lib/math.i | 3 - Lib/modula3/modula3.swg | 3 - Lib/modula3/modula3head.swg | 3 - Lib/modula3/typemaps.i | 3 - Lib/mzscheme/mzrun.swg | 3 - Lib/mzscheme/mzscheme.swg | 3 - Lib/mzscheme/std_common.i | 3 - Lib/mzscheme/std_map.i | 3 - Lib/mzscheme/std_pair.i | 3 - Lib/mzscheme/std_string.i | 3 - Lib/mzscheme/std_vector.i | 3 - Lib/mzscheme/stl.i | 3 - Lib/mzscheme/typemaps.i | 3 - Lib/ocaml/cstring.i | 3 - Lib/ocaml/director.swg | 3 - Lib/ocaml/ocaml.i | 3 - Lib/ocaml/ocamldec.swg | 3 - Lib/ocaml/std_common.i | 3 - Lib/ocaml/std_deque.i | 3 - Lib/ocaml/std_list.i | 3 - Lib/ocaml/std_map.i | 3 - Lib/ocaml/std_pair.i | 3 - Lib/ocaml/std_string.i | 3 - Lib/ocaml/std_vector.i | 3 - Lib/ocaml/stl.i | 3 - Lib/ocaml/typecheck.i | 3 - Lib/ocaml/typemaps.i | 3 - Lib/octave/octcontainer.swg | 3 - Lib/octave/octiterators.swg | 3 - Lib/perl5/perlmain.i | 3 - Lib/perl5/reference.i | 3 - Lib/perl5/std_common.i | 3 - Lib/perl5/std_list.i | 3 - Lib/perl5/std_map.i | 3 - Lib/perl5/std_pair.i | 3 - Lib/perl5/std_vector.i | 3 - Lib/perl5/stl.i | 3 - Lib/perl5/typemaps.i | 3 - Lib/php/const.i | 3 - Lib/php/director.swg | 3 - Lib/php/globalvar.i | 3 - Lib/php/php.swg | 3 - Lib/php/phpkw.swg | 3 - Lib/php/phprun.swg | 3 - Lib/php/std_common.i | 3 - Lib/php/std_map.i | 3 - Lib/php/std_pair.i | 3 - Lib/php/std_string.i | 3 - Lib/php/std_vector.i | 3 - Lib/php/stl.i | 3 - Lib/php/typemaps.i | 3 - Lib/pike/pike.swg | 3 - Lib/pike/pikerun.swg | 3 - Lib/pike/std_string.i | 3 - Lib/pointer.i | 3 - Lib/python/ccomplex.i | 3 - Lib/python/director.swg | 3 - Lib/python/embed15.i | 3 - Lib/python/file.i | 4 - Lib/python/pycontainer.swg | 3 - Lib/python/pyiterators.swg | 3 - Lib/python/pyrun.swg | 3 - Lib/python/typemaps.i | 3 - Lib/ruby/director.swg | 3 - Lib/ruby/rubyautodoc.swg | 15 +- Lib/ruby/rubycontainer.swg | 3 - Lib/ruby/rubycontainer_extended.swg | 24 +- Lib/ruby/rubyiterators.swg | 3 - Lib/ruby/rubyprimtypes.swg | 4 - Lib/ruby/rubyrun.swg | 3 - Lib/ruby/rubystdautodoc.swg | 12 +- Lib/ruby/rubytracking.swg | 3 - Lib/ruby/rubywstrings.swg | 20 +- Lib/ruby/stl.i | 3 - Lib/ruby/typemaps.i | 3 - Lib/std/_std_deque.i | 3 - Lib/std_except.i | 3 - Lib/stdint.i | 3 - Lib/stl.i | 3 - Lib/swigarch.i | 3 - Lib/swigrun.i | 3 - Lib/tcl/mactclinit.c | 93 - Lib/tcl/mactkinit.c | 3 - Lib/tcl/std_common.i | 3 - Lib/tcl/std_pair.i | 3 - Lib/tcl/std_vector.i | 3 - Lib/tcl/stl.i | 3 - Lib/tcl/tcl8.swg | 3 - Lib/tcl/tclinterp.i | 3 - Lib/tcl/tclopers.swg | 3 - Lib/tcl/tclresult.i | 3 - Lib/tcl/tclrun.swg | 3 - Lib/tcl/tclsh.i | 3 - Lib/tcl/tclwstrings.swg | 3 - Lib/tcl/typemaps.i | 3 - Lib/tcl/wish.i | 3 - Lib/typemaps/attribute.swg | 3 - Lib/typemaps/carrays.swg | 3 - Lib/typemaps/cdata.swg | 3 - Lib/typemaps/cmalloc.swg | 3 - Lib/typemaps/cpointer.swg | 3 - Lib/typemaps/cstrings.swg | 3 - Lib/typemaps/exception.swg | 3 - Lib/typemaps/ptrtypes.swg | 3 - Lib/typemaps/swigtypemaps.swg | 3 - Lib/typemaps/typemaps.swg | 3 - Lib/uffi/uffi.swg | 2 - Lib/wchar.i | 3 - Lib/windows.i | 3 - 346 files changed, 40 insertions(+), 12158 deletions(-) delete mode 100644 Examples/GIFPlot/Chicken/check.list delete mode 100644 Examples/GIFPlot/Chicken/full/Makefile delete mode 100644 Examples/GIFPlot/Chicken/full/README delete mode 100644 Examples/GIFPlot/Chicken/full/cmap delete mode 100644 Examples/GIFPlot/Chicken/full/gifplot.i delete mode 100644 Examples/GIFPlot/Chicken/full/test-gifplot.scm delete mode 100644 Examples/GIFPlot/Chicken/simple/Makefile delete mode 100644 Examples/GIFPlot/Chicken/simple/README delete mode 100644 Examples/GIFPlot/Chicken/simple/simple.i delete mode 100644 Examples/GIFPlot/Chicken/simple/test-simple.scm delete mode 100644 Examples/GIFPlot/Common-Lisp/full/cmap delete mode 100644 Examples/GIFPlot/Common-Lisp/full/gifplot.i delete mode 100644 Examples/GIFPlot/Common-Lisp/full/runme.lisp delete mode 100644 Examples/GIFPlot/Guile/check.list delete mode 100644 Examples/GIFPlot/Guile/full/Makefile delete mode 100644 Examples/GIFPlot/Guile/full/README delete mode 100644 Examples/GIFPlot/Guile/full/cmap delete mode 100644 Examples/GIFPlot/Guile/full/gifplot.i delete mode 100644 Examples/GIFPlot/Guile/full/runme.scm delete mode 100644 Examples/GIFPlot/Guile/simple/Makefile delete mode 100644 Examples/GIFPlot/Guile/simple/README delete mode 100644 Examples/GIFPlot/Guile/simple/runme.scm delete mode 100644 Examples/GIFPlot/Guile/simple/simple.i delete mode 100644 Examples/GIFPlot/Include/gifplot.h delete mode 100644 Examples/GIFPlot/Interface/gifplot.i delete mode 100644 Examples/GIFPlot/Java/check.list delete mode 100644 Examples/GIFPlot/Java/full/Makefile delete mode 100644 Examples/GIFPlot/Java/full/README delete mode 100644 Examples/GIFPlot/Java/full/cmap delete mode 100644 Examples/GIFPlot/Java/full/gifplot.i delete mode 100644 Examples/GIFPlot/Java/full/runme.java delete mode 100644 Examples/GIFPlot/Java/shadow/Makefile delete mode 100644 Examples/GIFPlot/Java/shadow/README delete mode 100644 Examples/GIFPlot/Java/shadow/cmap delete mode 100644 Examples/GIFPlot/Java/shadow/runme.java delete mode 100644 Examples/GIFPlot/Java/simple/Makefile delete mode 100644 Examples/GIFPlot/Java/simple/README delete mode 100644 Examples/GIFPlot/Java/simple/runme.java delete mode 100644 Examples/GIFPlot/Java/simple/simple.i delete mode 100644 Examples/GIFPlot/Lib/Makefile.in delete mode 100644 Examples/GIFPlot/Lib/color.c delete mode 100644 Examples/GIFPlot/Lib/font.c delete mode 100644 Examples/GIFPlot/Lib/frame.c delete mode 100644 Examples/GIFPlot/Lib/gif.c delete mode 100644 Examples/GIFPlot/Lib/matrix.c delete mode 100644 Examples/GIFPlot/Lib/pixmap.c delete mode 100644 Examples/GIFPlot/Lib/plot2d.c delete mode 100644 Examples/GIFPlot/Lib/plot3d.c delete mode 100644 Examples/GIFPlot/Makefile.in delete mode 100644 Examples/GIFPlot/Ocaml/check.list delete mode 100644 Examples/GIFPlot/Ocaml/full/Makefile delete mode 100644 Examples/GIFPlot/Ocaml/full/README delete mode 100644 Examples/GIFPlot/Ocaml/full/cmap delete mode 100644 Examples/GIFPlot/Ocaml/full/gifplot.i delete mode 100644 Examples/GIFPlot/Ocaml/full/runme.ml delete mode 100644 Examples/GIFPlot/Ocaml/simple/Makefile delete mode 100644 Examples/GIFPlot/Ocaml/simple/cmap delete mode 100644 Examples/GIFPlot/Ocaml/simple/runme.ml delete mode 100644 Examples/GIFPlot/Ocaml/simple/simple.i delete mode 100644 Examples/GIFPlot/Perl5/check.list delete mode 100644 Examples/GIFPlot/Perl5/full/Makefile delete mode 100644 Examples/GIFPlot/Perl5/full/README delete mode 100644 Examples/GIFPlot/Perl5/full/cmap delete mode 100644 Examples/GIFPlot/Perl5/full/gifplot.i delete mode 100644 Examples/GIFPlot/Perl5/full/runme.pl delete mode 100644 Examples/GIFPlot/Perl5/shadow/Makefile delete mode 100644 Examples/GIFPlot/Perl5/shadow/README delete mode 100644 Examples/GIFPlot/Perl5/shadow/cmap delete mode 100644 Examples/GIFPlot/Perl5/shadow/runme.pl delete mode 100644 Examples/GIFPlot/Perl5/simple/Makefile delete mode 100644 Examples/GIFPlot/Perl5/simple/README delete mode 100644 Examples/GIFPlot/Perl5/simple/runme.pl delete mode 100644 Examples/GIFPlot/Perl5/simple/simple.i delete mode 100644 Examples/GIFPlot/Php/check.list delete mode 100644 Examples/GIFPlot/Php/full/Makefile delete mode 100644 Examples/GIFPlot/Php/full/README delete mode 100644 Examples/GIFPlot/Php/full/cmap delete mode 100644 Examples/GIFPlot/Php/full/gifplot.i delete mode 100644 Examples/GIFPlot/Php/full/runme.php delete mode 100644 Examples/GIFPlot/Php/shadow/Makefile delete mode 100644 Examples/GIFPlot/Php/shadow/README delete mode 100644 Examples/GIFPlot/Php/shadow/cmap delete mode 100644 Examples/GIFPlot/Php/shadow/runme.php delete mode 100644 Examples/GIFPlot/Php/simple/Makefile delete mode 100644 Examples/GIFPlot/Php/simple/README delete mode 100644 Examples/GIFPlot/Php/simple/runme.php delete mode 100644 Examples/GIFPlot/Php/simple/simple.i delete mode 100644 Examples/GIFPlot/Pike/check.list delete mode 100644 Examples/GIFPlot/Pike/simple/Makefile delete mode 100644 Examples/GIFPlot/Pike/simple/README delete mode 100644 Examples/GIFPlot/Pike/simple/runme.pike delete mode 100644 Examples/GIFPlot/Pike/simple/simple.i delete mode 100644 Examples/GIFPlot/Python/check.list delete mode 100644 Examples/GIFPlot/Python/full/Makefile delete mode 100644 Examples/GIFPlot/Python/full/README delete mode 100644 Examples/GIFPlot/Python/full/cmap delete mode 100644 Examples/GIFPlot/Python/full/gifplot.i delete mode 100644 Examples/GIFPlot/Python/full/runme.py delete mode 100644 Examples/GIFPlot/Python/shadow/Makefile delete mode 100644 Examples/GIFPlot/Python/shadow/README delete mode 100644 Examples/GIFPlot/Python/shadow/cmap delete mode 100644 Examples/GIFPlot/Python/shadow/runme.py delete mode 100644 Examples/GIFPlot/Python/simple/Makefile delete mode 100644 Examples/GIFPlot/Python/simple/README delete mode 100644 Examples/GIFPlot/Python/simple/runme.py delete mode 100644 Examples/GIFPlot/Python/simple/simple.i delete mode 100644 Examples/GIFPlot/README delete mode 100644 Examples/GIFPlot/Ruby/check.list delete mode 100644 Examples/GIFPlot/Ruby/full/Makefile delete mode 100644 Examples/GIFPlot/Ruby/full/README delete mode 100644 Examples/GIFPlot/Ruby/full/cmap delete mode 100644 Examples/GIFPlot/Ruby/full/gifplot.i delete mode 100644 Examples/GIFPlot/Ruby/full/runme.rb delete mode 100644 Examples/GIFPlot/Ruby/shadow/Makefile delete mode 100644 Examples/GIFPlot/Ruby/shadow/README delete mode 100644 Examples/GIFPlot/Ruby/shadow/cmap delete mode 100644 Examples/GIFPlot/Ruby/shadow/runme.rb delete mode 100644 Examples/GIFPlot/Ruby/simple/Makefile delete mode 100644 Examples/GIFPlot/Ruby/simple/README delete mode 100644 Examples/GIFPlot/Ruby/simple/runme.rb delete mode 100644 Examples/GIFPlot/Ruby/simple/simple.i delete mode 100644 Examples/GIFPlot/Tcl/check.list delete mode 100644 Examples/GIFPlot/Tcl/full/Makefile delete mode 100644 Examples/GIFPlot/Tcl/full/README delete mode 100644 Examples/GIFPlot/Tcl/full/cmap delete mode 100644 Examples/GIFPlot/Tcl/full/gifplot.i delete mode 100644 Examples/GIFPlot/Tcl/full/runme.tcl delete mode 100644 Examples/GIFPlot/Tcl/mandel/Makefile delete mode 100644 Examples/GIFPlot/Tcl/mandel/README delete mode 100644 Examples/GIFPlot/Tcl/mandel/cmap delete mode 100644 Examples/GIFPlot/Tcl/mandel/display.tcl delete mode 100644 Examples/GIFPlot/Tcl/mandel/mandel.i delete mode 100644 Examples/GIFPlot/Tcl/mandel/mandel.tcl delete mode 100644 Examples/GIFPlot/Tcl/simple/Makefile delete mode 100644 Examples/GIFPlot/Tcl/simple/README delete mode 100644 Examples/GIFPlot/Tcl/simple/runme.tcl delete mode 100644 Examples/GIFPlot/Tcl/simple/simple.i delete mode 100644 Examples/chicken/zlib/Makefile delete mode 100644 Examples/chicken/zlib/README.html delete mode 100644 Examples/chicken/zlib/example.i delete mode 100644 Examples/chicken/zlib/test-zlib.scm delete mode 100644 Examples/xml/example_gif.i delete mode 100644 Lib/tcl/mactclinit.c diff --git a/Examples/GIFPlot/Chicken/check.list b/Examples/GIFPlot/Chicken/check.list deleted file mode 100644 index e75ee586a..000000000 --- a/Examples/GIFPlot/Chicken/check.list +++ /dev/null @@ -1,3 +0,0 @@ -# see top-level Makefile.in -full -simple diff --git a/Examples/GIFPlot/Chicken/full/Makefile b/Examples/GIFPlot/Chicken/full/Makefile deleted file mode 100644 index 2ae4fd7ea..000000000 --- a/Examples/GIFPlot/Chicken/full/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../preinst-swig -INTERFACE = gifplot.i -SRCS = -CXXSRCS = -TARGET = gifplot -INCLUDE = -I. -I../../Include -SWIGOPT = -I../../Include -CFLAGS = -VARIANT = -LIBS = -L../.. -lgifplot -lm - -# comment the following two lines to build a dynamic so file -CHICKEN_MAIN = test-gifplot.scm -VARIANT = _static - -all:: $(TARGET) - -$(TARGET): $(INTERFACE) $(SRCS) - $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) - -clean:: - $(MAKE) -f $(TOP)/Makefile chicken_clean - rm -f gifplot.scm image.gif - rm -f $(TARGET) diff --git a/Examples/GIFPlot/Chicken/full/README b/Examples/GIFPlot/Chicken/full/README deleted file mode 100644 index e5ddd7af1..000000000 --- a/Examples/GIFPlot/Chicken/full/README +++ /dev/null @@ -1,6 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The Scheme program 'test-gifplot.scm' does something a -little more interesting. You'll have to go look at the header file to -get a complete listing of the functions. - -`make' will build a static binary. Run ./gifplot to test it. diff --git a/Examples/GIFPlot/Chicken/full/cmap b/Examples/GIFPlot/Chicken/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9ICexact (round (max (min cc 239) 0))))) - (gifplot:Plot3D-solidquad p3 x y z1 (+ x dx) y z2 (+ x dx) (+ y dy) - z3 x (+ y dy) z4 - (gifplot:int->Pixel (+ c 16)))) - (y-loop (+ y dy) (+ j 1))))) - (x-loop (+ x dx) (+ i 1))))))) - -(display "Making a nice 3D plot...\n") -(drawsolid) - -(gifplot:FrameBuffer-writeGIF frame cmap "image.gif") -(display "Wrote image.gif\n") diff --git a/Examples/GIFPlot/Chicken/simple/Makefile b/Examples/GIFPlot/Chicken/simple/Makefile deleted file mode 100644 index 484e58390..000000000 --- a/Examples/GIFPlot/Chicken/simple/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../preinst-swig -INTERFACE = simple.i -SRCS = -CXXSRCS = -TARGET = simple -INCLUDE = -I. -I../../Include -SWIGOPT = -I../../Include -CFLAGS = -VARIANT = -LIBS = -L../.. -lgifplot -lm - -# comment the following two lines to build a dynamic so file -CHICKEN_MAIN = test-simple.scm -VARIANT = _static - -all:: $(TARGET) - -$(TARGET): $(INTERFACE) $(SRCS) - $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' CHICKEN_MAIN='$(CHICKEN_MAIN)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) - -clean:: - $(MAKE) -f $(TOP)/Makefile chicken_clean - rm -f simple.scm image.gif - rm -f $(TARGET) diff --git a/Examples/GIFPlot/Chicken/simple/README b/Examples/GIFPlot/Chicken/simple/README deleted file mode 100644 index 3b138f381..000000000 --- a/Examples/GIFPlot/Chicken/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -This is a very minimalistic example in which just a few functions -and constants from library are wrapped and used to draw some simple -shapes. - -`make' will build an exe. Run ./simple to test it. diff --git a/Examples/GIFPlot/Chicken/simple/simple.i b/Examples/GIFPlot/Chicken/simple/simple.i deleted file mode 100644 index 23ac8a856..000000000 --- a/Examples/GIFPlot/Chicken/simple/simple.i +++ /dev/null @@ -1,34 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned int Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants, which we redefine (from gifplot.h) so - that SWIG sees them */ -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - diff --git a/Examples/GIFPlot/Chicken/simple/test-simple.scm b/Examples/GIFPlot/Chicken/simple/test-simple.scm deleted file mode 100644 index 43250d8e9..000000000 --- a/Examples/GIFPlot/Chicken/simple/test-simple.scm +++ /dev/null @@ -1,29 +0,0 @@ -;;; Draw some simple shapes - -(declare (uses simple)) - -(display "Drawing some basic shapes\n") - -(define cmap (simple:new-ColorMap #f)) -(define f (simple:new-FrameBuffer 400 400)) - -;; Clear the picture -(simple:FrameBuffer-clear f (simple:BLACK)) - -;; Make a red box -(simple:FrameBuffer-box f 40 40 200 200 (simple:RED)) - -;; Make a blue circle -(simple:FrameBuffer-circle f 200 200 40 (simple:BLUE)) - -;; Make green line -(simple:FrameBuffer-line f 10 390 390 200 (simple:GREEN)) - -;; Write an image out to disk - -(simple:FrameBuffer-writeGIF f cmap "image.gif") -(display "Wrote image.gif\n") - -(simple:delete-FrameBuffer f) -(simple:delete-ColorMap cmap) - diff --git a/Examples/GIFPlot/Common-Lisp/full/cmap b/Examples/GIFPlot/Common-Lisp/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC -#include -#include -#include -#include -#include - -#ifndef GIFPLOT_H - -#ifdef SWIG -%nodefault; -#endif - -/* Pixel is 8-bits */ - -typedef unsigned char Pixel; -typedef float Zvalue; - -/* ------------------------------------------------------------------------ - ColorMap - - Definition and methods for colormaps - ------------------------------------------------------------------------ */ - -typedef struct ColorMap { - unsigned char *cmap; - char *name; -} ColorMap; - -extern ColorMap *new_ColorMap(char *filename); -extern void delete_ColorMap(ColorMap *c); -extern void ColorMap_default(ColorMap *c); -extern void ColorMap_assign(ColorMap *c, int index, int r, int g, int b); -extern int ColorMap_getitem(ColorMap *c, int index); -extern void ColorMap_setitem(ColorMap *c, int index, int value); -extern int ColorMap_write(ColorMap *c, char *filename); - -/* Some default colors */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - -/*------------------------------------------------------------------------- - FrameBuffer - - This structure defines a simple 8 bit framebuffer. - ------------------------------------------------------------------------- */ - -typedef struct FrameBuffer { - Pixel **pixels; - Zvalue **zbuffer; - unsigned int height; - unsigned int width; - int xmin; /* These are used for clipping */ - int ymin; - int xmax; - int ymax; -} FrameBuffer; - -#define ZMIN 1e+36 - -/* FrameBuffer Methods */ - -extern FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -extern void delete_FrameBuffer(FrameBuffer *frame); -extern int FrameBuffer_resize(FrameBuffer *frame, int width, int height); -extern void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -extern void FrameBuffer_plot(FrameBuffer *frame, int x, int y, Pixel color); -extern void FrameBuffer_horizontal(FrameBuffer *frame, int xmin, int xmax, int y, Pixel color); -extern void FrameBuffer_horizontalinterp(FrameBuffer *f, int xmin, int xmax, int y, Pixel c1, Pixel c2); -extern void FrameBuffer_vertical(FrameBuffer *frame, int ymin, int ymax, int x, Pixel color); -extern void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -extern void FrameBuffer_solidbox(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -extern void FrameBuffer_interpbox(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); -extern void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -extern void FrameBuffer_solidcircle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -extern void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -extern void FrameBuffer_setclip(FrameBuffer *frame, int xmin, int ymin, int xmax, int ymax); -extern void FrameBuffer_noclip(FrameBuffer *frame); -extern int FrameBuffer_makeGIF(FrameBuffer *frame, ColorMap *cmap, void *buffer, unsigned int maxsize); -extern int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); -extern void FrameBuffer_zresize(FrameBuffer *f, int width, int height); -extern void FrameBuffer_zclear(FrameBuffer *f); -extern void FrameBuffer_solidtriangle(FrameBuffer *f, int x1, int y1, int x2, int y2, int x3, int y3, Pixel c); -extern void FrameBuffer_interptriangle(FrameBuffer *f, int tx1, int ty1, Pixel c1, - int tx2, int ty2, Pixel c2, int tx3, int ty3, Pixel c3); - -#define HORIZONTAL 1 -#define VERTICAL 2 - -extern void FrameBuffer_drawchar(FrameBuffer *frame, int x, int y, int fgcolor, int bgcolor, char chr, int orientation); -extern void FrameBuffer_drawstring(FrameBuffer *f, int x, int y, int fgcolor, int bgcolor, char *text, int orientation); - -/* ------------------------------------------------------------------------ - PixMap - - The equivalent of "bit-maps". - ------------------------------------------------------------------------ */ - -typedef struct PixMap { - int width; - int height; - int centerx; - int centery; - int *map; -} PixMap; - -/* PIXMAP methods */ - -extern PixMap *new_PixMap(int width, int height, int centerx, int centery); -extern void delete_PixMap(PixMap *pm); -extern void PixMap_set(PixMap *pm, int x, int y, int pix); -extern void FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor); - -#define GIFPLOT_TRANSPARENT 0 -#define GIFPLOT_FOREGROUND 1 -#define GIFPLOT_BACKGROUND 2 - -/* ------------------------------------------------------------------------ - Plot2D - - Definition and methods for 2D plots. - ------------------------------------------------------------------------ */ - -typedef struct Plot2D { - FrameBuffer *frame; /* what frame buffer are we using */ - int view_xmin; /* Minimum coordinates of view region */ - int view_ymin; - int view_xmax; /* Maximum coordinates of view region */ - int view_ymax; - double xmin; /* Minimum coordinates of plot region */ - double ymin; - double xmax; /* Maximum coordinates of plot region */ - double ymax; - int xscale; /* Type of scaling (LINEAR, LOG, etc..) */ - int yscale; - double dx; /* Private scaling parameters */ - double dy; -} Plot2D; - -/* 2D Plot methods */ - -extern Plot2D *new_Plot2D(FrameBuffer *frame,double xmin,double ymin, double xmax, double ymax); -extern void delete_Plot2D(Plot2D *p2); -extern Plot2D *Plot2D_copy(Plot2D *p2); -extern void Plot2D_clear(Plot2D *p2, Pixel c); -extern void Plot2D_setview(Plot2D *p2, int vxmin, int vymin, int vxmax, int vymax); -extern void Plot2D_setrange(Plot2D *p2, double xmin, double ymin, double xmax, double ymax); -extern void Plot2D_setscale(Plot2D *p2, int xscale, int yscale); -extern void Plot2D_plot(Plot2D *p2, double x, double y, Pixel color); -extern void Plot2D_box(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color); -extern void Plot2D_solidbox(Plot2D *p2, double x1, double y1,double x2, double y2, Pixel color); -extern void Plot2D_interpbox(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); -extern void Plot2D_circle(Plot2D *p2, double x, double y, double radius, Pixel color); -extern void Plot2D_solidcircle(Plot2D *p2, double x, double y, double radius, Pixel color); -extern void Plot2D_line(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color); -extern void Plot2D_start(Plot2D *p2); -extern void Plot2D_drawpixmap(Plot2D *p2, PixMap *pm, double x, double y, Pixel color, Pixel bgcolor); -extern void Plot2D_xaxis(Plot2D *p2, double x, double y, double xtick, int ticklength, Pixel c); -extern void Plot2D_yaxis(Plot2D *p2, double x, double y, double ytick, int ticklength, Pixel c); -extern void Plot2D_triangle(Plot2D *p2, double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); -extern void Plot2D_solidtriangle(Plot2D *p2, double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); -extern void Plot2D_interptriangle(Plot2D *p2, double x1, double y1, Pixel c1, - double x2, double y2, Pixel c2, - double x3, double y3, Pixel c3); - -#define LINEAR 10 -#define LOG 11 - -/* ----------------------------------------------------------------------- - Matrix - - Operations on 4x4 transformation matrices and vectors. - Matrices are represented as a double array of 16 elements - ----------------------------------------------------------------------- */ - -typedef double *Matrix; -typedef struct GL_Vector { - double x; - double y; - double z; - double w; -} GL_Vector; - -extern Matrix new_Matrix(); -extern void delete_Matrix(Matrix a); -extern Matrix Matrix_copy(Matrix a); -extern void Matrix_multiply(Matrix a, Matrix b, Matrix c); -extern void Matrix_identity(Matrix a); -extern void Matrix_zero(Matrix a); -extern void Matrix_transpose(Matrix a, Matrix result); -extern void Matrix_invert(Matrix a, Matrix inva); -extern void Matrix_transform(Matrix a, GL_Vector *r, GL_Vector *t); -extern void Matrix_transform4(Matrix a, double rx, double ry, double rz, - double rw, GL_Vector *t); - -extern void Matrix_print(Matrix a); -extern void Matrix_translate(Matrix a, double tx, double ty, double tz); -extern void Matrix_rotatex(Matrix a, double deg); -extern void Matrix_rotatey(Matrix a, double deg); -extern void Matrix_rotatez(Matrix a, double deg); - -/* ----------------------------------------------------------------------- - Plot3D - - Data Structure for 3-D plots - ------------------------------------------------------------------------ */ - -typedef struct Plot3D { - FrameBuffer *frame; /* Frame buffer being used */ - int view_xmin; /* Viewing region */ - int view_ymin; - int view_xmax; - int view_ymax; - double xmin; /* Bounding box */ - double ymin; - double zmin; - double xmax; - double ymax; - double zmax; - double xcenter; /* Center point */ - double ycenter; - double zcenter; - double fovy; /* Field of view */ - double aspect; /* Aspect ratio */ - double znear; /* near "clipping" plane */ - double zfar; /* far "clipping" plane */ - Matrix center_mat; /* Matrix used for centering the model */ - Matrix model_mat; /* Model rotation matrix */ - Matrix view_mat; /* Viewing matrix */ - Matrix fullmodel_mat; /* Full model matrix. Used by sphere plot */ - Matrix trans_mat; /* Total transformation matrix */ - double lookatz; /* Where is the z-lookat point */ - double xshift; /* Used for translation and stuff */ - double yshift; - double zoom; - int width; - int height; - int pers_mode; /* Perspective mode (private) */ - double ortho_left,ortho_right,ortho_bottom,ortho_top; -} Plot3D; - -extern Plot3D *new_Plot3D(FrameBuffer *frame, double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax); -extern void delete_Plot3D(Plot3D *p3); -extern Plot3D *Plot3D_copy(Plot3D *p3); -extern void Plot3D_clear(Plot3D *p3, Pixel Color); -extern void Plot3D_perspective(Plot3D *p3, double fovy, double znear, double zfar); -extern void Plot3D_ortho(Plot3D *p3, double left, double right, double top, double bottom); -extern void Plot3D_lookat(Plot3D *p3, double z); -extern void Plot3D_autoperspective(Plot3D *p3, double fovy); -extern void Plot3D_autoortho(Plot3D *p3); -extern void Plot3D_rotx(Plot3D *p3, double deg); -extern void Plot3D_roty(Plot3D *p3, double deg); -extern void Plot3D_rotz(Plot3D *p3, double deg); -extern void Plot3D_rotl(Plot3D *p3, double deg); -extern void Plot3D_rotr(Plot3D *p3, double deg); -extern void Plot3D_rotd(Plot3D *p3, double deg); -extern void Plot3D_rotu(Plot3D *p3, double deg); -extern void Plot3D_rotc(Plot3D *p3, double deg); -extern void Plot3D_zoom(Plot3D *p3, double percent); -extern void Plot3D_left(Plot3D *p3, double percent); -extern void Plot3D_right(Plot3D *p3, double percent); -extern void Plot3D_down(Plot3D *p3, double percent); -extern void Plot3D_up(Plot3D *p3, double percent); -extern void Plot3D_center(Plot3D *p3, double cx, double cy); - -extern void Plot3D_plot(Plot3D *p3, double x, double y, double z, Pixel Color); - -extern void Plot3D_setview(Plot3D *p3, int vxmin, int vymin, int vxmax, int vymax); -extern void Plot3D_start(Plot3D *p3); -extern void Plot3D_line(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, Pixel color); -extern void Plot3D_triangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color); -extern void Plot3D_solidtriangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color); - -extern void Plot3D_interptriangle(Plot3D *p3, - double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3); - -extern void Plot3D_quad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color); - -extern void Plot3D_solidquad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color); - -extern void Plot3D_interpquad(Plot3D *p3, double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3, - double x4, double y4, double z4, Pixel c4); - - -extern void Plot3D_solidsphere(Plot3D *p3, double x, double y, double z, double radius,Pixel c); - -extern void Plot3D_outlinesphere(Plot3D *p3, double x, double y, double z, double radius,Pixel c, Pixel bc); - -extern PixMap PixMap_SQUARE; -extern PixMap PixMap_TRIANGLE; -extern PixMap PixMap_CROSS; - -#endif -#define GIFPLOT_H - - - diff --git a/Examples/GIFPlot/Interface/gifplot.i b/Examples/GIFPlot/Interface/gifplot.i deleted file mode 100644 index fdf661c5e..000000000 --- a/Examples/GIFPlot/Interface/gifplot.i +++ /dev/null @@ -1,264 +0,0 @@ -// -// Graphics module -// -%module gifplot -%{ -#include "gifplot.h" -%} - -#if defined(SWIGJAVA ) || defined(SWIGPHP) - %rename(make_default) ColorMap::default(); -#endif - -%rename(__getitem__) ColorMap::getitem(int index); -%rename(__setitem__) ColorMap::setitem(int index, int value); - -/* Pixel is 8-bits */ - -typedef unsigned char Pixel; -typedef float Zvalue; - -/* ------------------------------------------------------------------------ - ColorMap - - Definition and methods for colormaps - ------------------------------------------------------------------------ */ - -typedef struct ColorMap { - char *name; - -// -// %extend adds some C methods to this structure to make it -// look like a C++ class in Python. -// These are really named things like ColorMap_default, ColorMap_assign, etc... - - %extend { - ColorMap(char *filename); - ~ColorMap(); - void default(); - void assign(int index,int r, int g, int b); - int getitem(int index); - void setitem(int index, int value); - int write(char *filename); - } -} ColorMap; - -/* Some default colors */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - -/*------------------------------------------------------------------------- - FrameBuffer - - This structure defines a simple 8 bit framebuffer. - ------------------------------------------------------------------------- */ - -typedef struct FrameBuffer { - unsigned int height; - unsigned int width; - int xmin; /* These are used for clipping */ - int ymin; - int xmax; - int ymax; - %extend { - FrameBuffer(unsigned int width, unsigned int height); - ~FrameBuffer(); - void resize(int width, int height); - void clear(Pixel color); - void plot(int x, int y, Pixel color); - void horizontal(int xmin, int xmax, int y, Pixel color); - void horizontalinterp(int xmin, int xmax, int y, Pixel c1, Pixel c2); - void vertical(int ymin, int ymax, int x, Pixel color); - void box(int x1, int y1, int x2, int y2, Pixel color); - void solidbox(int x1, int y1, int x2, int y2, Pixel color); - void interpbox(int x1, int y1, int x2, int y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); - void circle(int x1, int y1, int radius, Pixel color); - void solidcircle(int x1, int y1, int radius, Pixel color); - void line(int x1, int y1, int x2, int y2, Pixel color); - void setclip(int xmin, int ymin, int xmax, int ymax); - void noclip(); - int makeGIF(ColorMap *cmap, void *buffer, unsigned int maxsize); - void zresize(int width, int height); - void zclear(); - void drawchar(int x, int y, int fgcolor, int bgcolor, char chr, int orientation); - void drawstring(int x, int y, int fgcolor, int bgcolor, char *text, int orientation); - void drawpixmap(PixMap *pm, int x, int y, int fgcolor, int bgcolor); - int writeGIF(ColorMap *cmap, char *filename); - } -} FrameBuffer; - -#define HORIZONTAL 1 -#define VERTICAL 2 - -/* -------------------------------------------------------------------------- - PixMap - - The equivalent of "bit-maps". - -------------------------------------------------------------------------- */ - -/* PIXMAP methods */ - -extern PixMap *new_PixMap(int width, int height, int centerx, int centery); -extern void delete_PixMap(PixMap *pm); -extern void PixMap_set(PixMap *pm, int x, int y, int pix); - -#define GIFPLOT_TRANSPARENT 0 -#define GIFPLOT_FOREGROUND 1 -#define GIFPLOT_BACKGROUND 2 - -/* -------------------------------------------------------------------------- - Plot2D - - Definition and methods for 2D plots. - --------------------------------------------------------------------------- */ - -typedef struct Plot2D { - FrameBuffer *frame; - int view_xmin; /* Minimum coordinates of view region */ - int view_ymin; - int view_xmax; /* Maximum coordinates of view region */ - int view_ymax; - double xmin; /* Minimum coordinates of plot region */ - double ymin; - double xmax; /* Maximum coordinates of plot region */ - double ymax; - int xscale; /* Type of scaling (LINEAR, LOG, etc..) */ - int yscale; - %extend { - Plot2D(FrameBuffer *frame,double xmin,double ymin, double xmax, double ymax); - ~Plot2D(); - Plot2D *copy(); - void clear(Pixel c); - void setview(int vxmin, int vymin, int vxmax, int vymax); - void setrange(double xmin, double ymin, double xmax, double ymax); - void setscale(int xscale, int yscale); - void plot(double x, double y, Pixel color); - void box(double x1, double y1, double x2, double y2, Pixel color); - void solidbox(double x1, double y1, double x2, double y2, Pixel color); - void interpbox(double x1, double y1, double x2, double y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); - - void circle(double x, double y, double radius, Pixel color); - void solidcircle(double x, double y, double radius, Pixel color); - void line(double x1, double y1, double x2, double y2, Pixel color); - void start(); - void drawpixmap(PixMap *pm, double x, double y, Pixel color, Pixel bgcolor); - void xaxis(double x, double y, double xtick, int ticklength, Pixel color); - void yaxis(double x, double y, double ytick, int ticklength, Pixel color); - void triangle(double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); - - void solidtriangle(double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); - - void interptriangle(double x1, double y1, Pixel c1, - double x2, double y2, Pixel c2, - double x3, double y3, Pixel c3); - - } -} Plot2D; - -#define LINEAR 10 -#define LOG 11 - -/* ------------------------------------------------------------------------------ - Plot3D - - Data Structure for 3-D plots - ------------------------------------------------------------------------------ */ - -typedef struct Plot3D { - FrameBuffer *frame; - int view_xmin; /* Viewing region */ - int view_ymin; - int view_xmax; - int view_ymax; - double xmin; /* Bounding box */ - double ymin; - double zmin; - double xmax; - double ymax; - double zmax; - double xcenter; /* Center point */ - double ycenter; - double zcenter; - double fovy; /* Field of view */ - double aspect; /* Aspect ratio */ - double znear; /* near "clipping" plane */ - double zfar; /* far "clipping" plane */ - double lookatz; /* Where is the z-lookat point */ - double xshift; /* Used for translation and stuff */ - double yshift; - %extend { - Plot3D(FrameBuffer *frame, double xmin, double ymin, double zmin, double xmax, double ymax, double zmax); - ~Plot3D(); - Plot3D *copy(); - void clear(Pixel bgcolor); - void perspective( double fovy, double znear, double zfar); - void lookat( double z); - void autoperspective( double fovy); - void ortho(double left, double right, double bottom, double top); - void autoortho(); - void rotx( double deg); - void roty( double deg); - void rotz( double deg); - void rotl( double deg); - void rotr( double deg); - void rotd( double deg); - void rotu( double deg); - void rotc( double deg); - void zoom( double percent); - void left( double percent); - void right( double percent); - void down( double percent); - void up( double percent); - void center( double cx, double cy); - void plot( double x, double y, double z, Pixel Color); - void setview( int vxmin, int vymin, int vxmax, int vymax); - void start(); - void line( double x1, double y1, double z1, - double x2, double y2, double z2, Pixel color); - void triangle( double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color); - void solidtriangle( double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color); - void interptriangle(double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3); - void quad( double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color); - void solidquad( double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color); - void interpquad( double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3, - double x4, double y4, double z4, Pixel c4); - void solidsphere( double x, double y, double z, double radius,Pixel c); - void outlinesphere( double x, double y, double z, double radius,Pixel c, Pixel bc); - } -} Plot3D; - -#ifndef SWIGJAVA -/* These directives create constants of a specific type. They - do not correspond to any C variable or declared constant in the - header file */ -%constant PixMap * SQUARE = &PixMap_SQUARE; -%constant PixMap * TRIANGLE = &PixMap_TRIANGLE; -%constant PixMap * CROSS = &PixMap_CROSS; -#endif - - - - diff --git a/Examples/GIFPlot/Java/check.list b/Examples/GIFPlot/Java/check.list deleted file mode 100644 index 13de977af..000000000 --- a/Examples/GIFPlot/Java/check.list +++ /dev/null @@ -1,4 +0,0 @@ -# see top-level Makefile.in -full -shadow -simple diff --git a/Examples/GIFPlot/Java/full/Makefile b/Examples/GIFPlot/Java/full/Makefile deleted file mode 100644 index 8f167237d..000000000 --- a/Examples/GIFPlot/Java/full/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Include -noproxy -SRCS = -TARGET = gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Java/full/README b/Examples/GIFPlot/Java/full/README deleted file mode 100644 index 93463ea30..000000000 --- a/Examples/GIFPlot/Java/full/README +++ /dev/null @@ -1,8 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The program 'runme.java' does something a little more -interesting. After doing a make, run it using 'java runme'. You'll have to go -look at the header file to get a complete listing of the functions. - -Note the differences in the runme.java files between this example and the -'full' example. This example does not use shadow classes. - diff --git a/Examples/GIFPlot/Java/full/cmap b/Examples/GIFPlot/Java/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239) c = 239; - gifplot.Plot3D_solidquad(p3,x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,(short)(c+16)); - y = y + dy; - } - x = x + dx; - } - - gifplot.FrameBuffer_writeGIF(frame,cmap,"image.gif"); - System.out.println( "Wrote image.gif" ); - } - - // Here is the function to plot - public static double func(double x, double y) { - return 5*java.lang.Math.cos(2*java.lang.Math.sqrt(x*x+y*y))*java.lang.Math.exp(-0.3*java.lang.Math.sqrt(x*x+y*y)); - } -} diff --git a/Examples/GIFPlot/Java/shadow/Makefile b/Examples/GIFPlot/Java/shadow/Makefile deleted file mode 100644 index 8062c2700..000000000 --- a/Examples/GIFPlot/Java/shadow/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -outcurrentdir -SRCS = -TARGET = gifplot -INTERFACEDIR = ../../Interface/ -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' java - javac *.java - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Java/shadow/README b/Examples/GIFPlot/Java/shadow/README deleted file mode 100644 index b06c5a8f1..000000000 --- a/Examples/GIFPlot/Java/shadow/README +++ /dev/null @@ -1,5 +0,0 @@ -This example uses the file in ../../Interface/gifplot.i to build -an interface with shadow classes. After doing a make, run the program runme, ie: 'java runme'. - -Note the differences in the runme.java files between this example and the -'full' example. This example uses the shadow classes. diff --git a/Examples/GIFPlot/Java/shadow/cmap b/Examples/GIFPlot/Java/shadow/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239) c = 239; - p3.solidquad(x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,(short)(c+16)); - y = y + dy; - } - x = x + dx; - } - - frame.writeGIF(cmap,"image.gif"); - System.out.println( "Wrote image.gif" ); - } - - // Here is the function to plot - public static double func(double x, double y) { - return 5*java.lang.Math.cos(2*java.lang.Math.sqrt(x*x+y*y))*java.lang.Math.exp(-0.3*java.lang.Math.sqrt(x*x+y*y)); - } -} diff --git a/Examples/GIFPlot/Java/simple/Makefile b/Examples/GIFPlot/Java/simple/Makefile deleted file mode 100644 index d707fd458..000000000 --- a/Examples/GIFPlot/Java/simple/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -noproxy -SRCS = -TARGET = simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java - javac *.java - - -clean:: - $(MAKE) -f $(TOP)/Makefile java_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Java/simple/README b/Examples/GIFPlot/Java/simple/README deleted file mode 100644 index 13ff49611..000000000 --- a/Examples/GIFPlot/Java/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -This is a very minimalistic example in which just a few functions -and constants from library are wrapped and used to draw some simple -shapes. After doing a make, run the java program, ie 'java runme'. - - diff --git a/Examples/GIFPlot/Java/simple/runme.java b/Examples/GIFPlot/Java/simple/runme.java deleted file mode 100644 index 2d8d2bb48..000000000 --- a/Examples/GIFPlot/Java/simple/runme.java +++ /dev/null @@ -1,41 +0,0 @@ - -public class runme { - - static { - try { - System.loadLibrary("simple"); - } catch (UnsatisfiedLinkError e) { - System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); - System.exit(1); - } - } - - public static void main(String argv[]) { - - // Draw some simple shapes - System.out.println( "Drawing some basic shapes" ); - - SWIGTYPE_p_ColorMap cmap = simple.new_ColorMap(null); - SWIGTYPE_p_FrameBuffer f = simple.new_FrameBuffer(400,400); - - // Clear the picture - simple.FrameBuffer_clear(f,(short)simple.BLACK); - - // Make a red box - simple.FrameBuffer_box(f,40,40,200,200,(short)simple.RED); - - // Make a blue circle - simple.FrameBuffer_circle(f,200,200,40,(short)simple.BLUE); - - // Make green line - simple.FrameBuffer_line(f,10,390,390,200, (short)simple.GREEN); - - // Write an image out to disk - - simple.FrameBuffer_writeGIF(f,cmap,"image.gif"); - System.out.println( "Wrote image.gif" ); - - simple.delete_FrameBuffer(f); - simple.delete_ColorMap(cmap); - } -} diff --git a/Examples/GIFPlot/Java/simple/simple.i b/Examples/GIFPlot/Java/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Java/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/GIFPlot/Lib/Makefile.in b/Examples/GIFPlot/Lib/Makefile.in deleted file mode 100644 index 9db828eb2..000000000 --- a/Examples/GIFPlot/Lib/Makefile.in +++ /dev/null @@ -1,22 +0,0 @@ -CC = @CC@ -CCSHARED= @CCSHARED@ -INCLUDES= -I../Include -CFLAGS = -O -SRCS = frame.c color.c plot2d.c plot3d.c font.c pixmap.c matrix.c gif.c -OBJS = $(SRCS:.c=.@OBJEXT@) -AR = @AR@ -RANLIB = @RANLIB@ -TARGET = ../libgifplot.a - -.c.@OBJEXT@: - $(CC) $(CCSHARED) $(INCLUDES) $(CFLAGS) -c -o $*.@OBJEXT@ $< - -all: $(OBJS) - @rm -f ../libgifplot.a - $(AR) cr $(TARGET) $(OBJS) - $(RANLIB) $(TARGET) - -clean: - rm -f *.@OBJEXT@ *~ $(TARGET) - -check: all diff --git a/Examples/GIFPlot/Lib/color.c b/Examples/GIFPlot/Lib/color.c deleted file mode 100644 index 7d79baca9..000000000 --- a/Examples/GIFPlot/Lib/color.c +++ /dev/null @@ -1,143 +0,0 @@ -/* ----------------------------------------------------------------------------- - * color.c - * - * Colormaps - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define COLORMAP -#include "gifplot.h" -#include - -/* ------------------------------------------------------------------------ - ColorMap *new_ColorMap(char *filename) - - Read a colormap from a file. - ------------------------------------------------------------------------ */ - -ColorMap *new_ColorMap(char *filename) { - ColorMap *c; - FILE *cm; - void ColorMap_default(ColorMap *); - - if (!filename) { - c = (ColorMap *) malloc(sizeof(ColorMap)); - c->cmap = (unsigned char *) malloc(768*sizeof(char)); - c->name = 0; - ColorMap_default(c); - return c; - } - if (strlen(filename) == 0) { - c = (ColorMap *) malloc(sizeof(ColorMap)); - c->cmap = (unsigned char *) malloc(768*sizeof(char)); - ColorMap_default(c); - return c; - } - if ((cm = fopen(filename,"rb")) == NULL) { - return (ColorMap *) 0; - } - c = (ColorMap *) malloc(sizeof(ColorMap)); - c->cmap = (unsigned char *) malloc(768*sizeof(char)); - if (fread(c->cmap, 768, 1, cm) != 1) { - free((char *)c->cmap); - free((char *)c); - fclose(cm); - return (ColorMap *) 0; - } - fclose(cm); - c->name = (char *) malloc(strlen(filename)+1); - strcpy(c->name, filename); - ColorMap_default(c); - return c; -} - -/* -------------------------------------------------------------------------- - delete_ColorMap(ColorMap *cm) - - Destroy a ColorMap - -------------------------------------------------------------------------- */ - -void delete_ColorMap(ColorMap *cm) { - if (cm) { - free((char *)cm->cmap); - if (cm->name) - free((char *)cm->name); - free((char *)cm); - } -} - -/* -------------------------------------------------------------------------- - ColorMap_default(ColorMap *cm) - - This function fills in default values for the first 8 entries of the - colormap. These are *fixed* values---used internally. - -------------------------------------------------------------------------- */ - -void ColorMap_default(ColorMap *cm) { - unsigned char *r,*g,*b; - if (cm) { - r = cm->cmap; - g = cm->cmap+256; - b = cm->cmap+512; - - r[0] = 0; g[0] = 0; b[0] = 0; /* BLACK */ - r[1] = 255; g[1] = 255; b[1] = 255; /* WHITE */ - r[2] = 255; g[2] = 0; b[2] = 0; /* RED */ - r[3] = 0; g[3] = 255; b[3] = 0; /* GREEN */ - r[4] = 0; g[4] = 0; b[4] = 255; /* BLUE */ - r[5] = 255; g[5] = 255; b[5] = 0; /* YELLOW */ - r[6] = 0; g[6] = 255; b[6] = 255; /* CYAN */ - r[7] = 255; g[7] = 0; b[7] = 255; /* MAGENTA */ - } -} - -void ColorMap_assign(ColorMap *cm, int index, int r, int g, int b) { - unsigned char *rb,*gb,*bb; - - rb = cm->cmap; - gb = cm->cmap+256; - bb = cm->cmap+512; - - rb[index] = r; - gb[index] = g; - bb[index] = b; -} - -int ColorMap_getitem(ColorMap *cm, int index) { - if ((index < 0) && (index >= 768)) return -1; - return cm->cmap[index]; -} - -void ColorMap_setitem(ColorMap *cm, int index, int value) { - if ((index < 0) && (index >= 768)) return; - cm->cmap[index]=value; -} - -/* -------------------------------------------------------------------- - ColorMap_write(ColorMap *cm, char *filename) - - Write out a colormap to disk. - -------------------------------------------------------------------- */ - -int ColorMap_write(ColorMap *cm, char *filename) { - - FILE *f; - if (!cm) return -1; - if (!filename) return -1; - if (strlen(filename) == 0) return -1; - - f = fopen(filename,"w"); - - if (fwrite(cm->cmap,768,1,f) != 1) { - fclose(f); - return -1; - } - fclose(f); - return 0; -} - -#undef COLORMAP diff --git a/Examples/GIFPlot/Lib/font.c b/Examples/GIFPlot/Lib/font.c deleted file mode 100644 index b30ee9b14..000000000 --- a/Examples/GIFPlot/Lib/font.c +++ /dev/null @@ -1,705 +0,0 @@ -/* ----------------------------------------------------------------------------- - * font.c - * - * Some basic fonts. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define FONT -#include "gifplot.h" - -static char Char_A[80] = "\ -...x....\ -...x....\ -..x.x...\ -..x.x...\ -.x...x..\ -.xxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -........"; - -static char Char_B[80] = "\ -xxxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -xxxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -xxxxxx..\ -........"; - -static char Char_C[80] = "\ -..xxxx..\ -.x....x.\ -x.......\ -x.......\ -x.......\ -x.......\ -x.......\ -.x....x.\ -..xxxx..\ -........"; - -static char Char_D[80] = "\ -xxxxx...\ -x....x..\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x....x..\ -xxxxx...\ -........"; -static char Char_E[80] = "\ -xxxxxxx.\ -x.......\ -x.......\ -x.......\ -xxxxx...\ -x.......\ -x.......\ -x.......\ -xxxxxxx.\ -........"; -static char Char_F[80] = "\ -xxxxxxx.\ -x.......\ -x.......\ -x.......\ -xxxxx...\ -x.......\ -x.......\ -x.......\ -x.......\ -........"; -static char Char_G[80] = "\ -.xxxxx..\ -x.....x.\ -x.......\ -x.......\ -x...xxx.\ -x.....x.\ -x.....x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_H[80] = "\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -xxxxxxx.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -........"; -static char Char_I[80] = "\ -xxxxxxx.\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -xxxxxxx.\ -........"; -static char Char_J[80] = "\ -......x.\ -......x.\ -......x.\ -......x.\ -......x.\ -......x.\ -x.....x.\ -.x...x..\ -..xxx...\ -........"; -static char Char_K[80] = "\ -x.....x.\ -x....x..\ -x...x...\ -x..x....\ -xxx.....\ -x..x....\ -x...x...\ -x....x..\ -x.....x.\ -........"; -static char Char_L[80] = "\ -x.......\ -x.......\ -x.......\ -x.......\ -x.......\ -x.......\ -x.......\ -x.......\ -xxxxxxx.\ -........"; -static char Char_M[80] = "\ -x.....x.\ -xx...xx.\ -xx...xx.\ -x.x.x.x.\ -x.x.x.x.\ -x..x..x.\ -x..x..x.\ -x.....x.\ -x.....x.\ -........"; -static char Char_N[80] = "\ -x.....x.\ -xx....x.\ -x.x...x.\ -x.x...x.\ -x..x..x.\ -x...x.x.\ -x...x.x.\ -x....xx.\ -x.....x.\ -........"; -static char Char_O[80] = "\ -.xxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_P[80] = "\ -xxxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -xxxxxx..\ -x.......\ -x.......\ -x.......\ -x.......\ -........"; -static char Char_Q[80] = "\ -.xxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x...x.x.\ -x....x..\ -.xxxx.x.\ -........"; -static char Char_R[80] = "\ -xxxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -xxxxxx..\ -x..x....\ -x...x...\ -x....x..\ -x.....x.\ -........"; -static char Char_S[80] = "\ -.xxxxx..\ -x.....x.\ -x.......\ -x.......\ -.xxxxx..\ -......x.\ -......x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_T[80] = "\ -xxxxxxx.\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -........"; -static char Char_U[80] = "\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_V[80] = "\ -x.....x.\ -x.....x.\ -.x...x..\ -.x...x..\ -..x.x...\ -..x.x...\ -...x....\ -...x....\ -...x....\ -........"; -static char Char_W[80] = "\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x.....x.\ -x..x..x.\ -x..x..x.\ -x.x.x.x.\ -.x...x..\ -........"; -static char Char_X[80] = "\ -x.....x.\ -x.....x.\ -.x...x..\ -..x.x...\ -...x....\ -..x.x...\ -.x...x..\ -x.....x.\ -x.....x.\ -........"; -static char Char_Y[80] = "\ -x.....x.\ -x.....x.\ -.x...x..\ -..x.x...\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -........"; -static char Char_Z[80] = "\ -xxxxxxx.\ -......x.\ -.....x..\ -....x...\ -...x....\ -..x.....\ -.x......\ -x.......\ -xxxxxxx.\ -........"; -static char Char_0[80] = "\ -.xxxxx..\ -x....xx.\ -x...x.x.\ -x..x..x.\ -x..x..x.\ -x.x...x.\ -x.x...x.\ -xx....x.\ -.xxxxx..\ -........"; -static char Char_1[80] = "\ -...x....\ -..xx....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -...x....\ -..xxx...\ -........"; -static char Char_2[80] = "\ -..xxxx..\ -.x....x.\ -x.....x.\ -.....x..\ -....x...\ -...x....\ -..x.....\ -.x......\ -xxxxxxx.\ -........"; -static char Char_3[80] = "\ -.xxxxx..\ -x.....x.\ -......x.\ -......x.\ -...xxx..\ -......x.\ -......x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_4[80] = "\ -....xx..\ -...x.x..\ -..x..x..\ -.x...x..\ -xxxxxxx.\ -.....x..\ -.....x..\ -.....x..\ -.....x..\ -........"; -static char Char_5[80] = "\ -xxxxxxx.\ -x.......\ -x.......\ -x.......\ -xxxxxx..\ -......x.\ -......x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_6[80] = "\ -....xxx.\ -..xx....\ -.x......\ -x.......\ -x.xxx...\ -xx...x..\ -x.....x.\ -.x...x..\ -..xxx...\ -........"; -static char Char_7[80] = "\ -xxxxxxx.\ -x.....x.\ -.....x..\ -....x...\ -...x....\ -..x.....\ -.x......\ -x.......\ -x.......\ -........"; -static char Char_8[80] = "\ -.xxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -.xxxxx..\ -x.....x.\ -x.....x.\ -x.....x.\ -.xxxxx..\ -........"; -static char Char_9[80] = "\ -..xxxx..\ -.x....x.\ -x.....x.\ -x....xx.\ -.xxxx.x.\ -......x.\ -......x.\ -....xx..\ -.xxx....\ -........"; -static char Char_MINUS[80] = "\ -........\ -........\ -........\ -........\ -.xxxxxx.\ -........\ -........\ -........\ -........\ -........"; -static char Char_PLUS[80] = "\ -........\ -........\ -...x....\ -...x....\ -.xxxxx..\ -...x....\ -...x....\ -........\ -........\ -........"; -static char Char_EQUAL[80] = "\ -........\ -........\ -........\ -.xxxxx..\ -........\ -.xxxxx..\ -........\ -........\ -........\ -........"; -static char Char_LPAREN[80] = "\ -....x...\ -...x....\ -..x.....\ -.x......\ -.x......\ -.x......\ -..x.....\ -...x....\ -....x...\ -........"; -static char Char_RPAREN[80] = "\ -...x....\ -....x...\ -.....x..\ -......x.\ -......x.\ -......x.\ -.....x..\ -....x...\ -...x....\ -........"; -static char Char_QUOTE[80] = "\ -..x.x...\ -..x.x...\ -........\ -........\ -........\ -........\ -........\ -........\ -........\ -........"; -static char Char_COLON[80] = "\ -........\ -........\ -...xx...\ -...xx...\ -........\ -...xx...\ -...xx...\ -........\ -........\ -........"; -static char Char_PERIOD[80] = "\ -........\ -........\ -........\ -........\ -........\ -........\ -........\ -...xx...\ -...xx...\ -........"; -static char Char_COMMA[80] = "\ -........\ -........\ -........\ -........\ -........\ -........\ -...xx...\ -...xx...\ -....x...\ -...x...."; - -static char Char_SLASH[80] = "\ -........\ -......x.\ -.....x..\ -....x...\ -...x....\ -..x.....\ -.x......\ -x.......\ -........\ -........"; - -static char Char_SPACE[80] = "\ -........\ -........\ -........\ -........\ -........\ -........\ -........\ -........\ -........\ -........"; - -static char *GP_Font[128]; -static int InitGP_Font = 0; - -static void initGP_Fonts(void) { - - int i; - for (i = 0; i < 128; i++) - GP_Font[i] = (char *) 0; - - GP_Font['A'] = GP_Font['a'] = Char_A; - GP_Font['B'] = GP_Font['b'] = Char_B; - GP_Font['C'] = GP_Font['c'] = Char_C; - GP_Font['D'] = GP_Font['d'] = Char_D; - GP_Font['E'] = GP_Font['e'] = Char_E; - GP_Font['F'] = GP_Font['f'] = Char_F; - GP_Font['G'] = GP_Font['g'] = Char_G; - GP_Font['H'] = GP_Font['h'] = Char_H; - GP_Font['I'] = GP_Font['i'] = Char_I; - GP_Font['J'] = GP_Font['j'] = Char_J; - GP_Font['K'] = GP_Font['k'] = Char_K; - GP_Font['L'] = GP_Font['l'] = Char_L; - GP_Font['M'] = GP_Font['m'] = Char_M; - GP_Font['N'] = GP_Font['n'] = Char_N; - GP_Font['O'] = GP_Font['o'] = Char_O; - GP_Font['P'] = GP_Font['p'] = Char_P; - GP_Font['Q'] = GP_Font['q'] = Char_Q; - GP_Font['R'] = GP_Font['r'] = Char_R; - GP_Font['S'] = GP_Font['s'] = Char_S; - GP_Font['T'] = GP_Font['t'] = Char_T; - GP_Font['U'] = GP_Font['u'] = Char_U; - GP_Font['V'] = GP_Font['v'] = Char_V; - GP_Font['W'] = GP_Font['w'] = Char_W; - GP_Font['X'] = GP_Font['x'] = Char_X; - GP_Font['Y'] = GP_Font['y'] = Char_Y; - GP_Font['Z'] = GP_Font['z'] = Char_Z; - GP_Font['0'] = Char_0; - GP_Font['1'] = Char_1; - GP_Font['2'] = Char_2; - GP_Font['3'] = Char_3; - GP_Font['4'] = Char_4; - GP_Font['5'] = Char_5; - GP_Font['6'] = Char_6; - GP_Font['7'] = Char_7; - GP_Font['8'] = Char_8; - GP_Font['9'] = Char_9; - GP_Font['.'] = Char_PERIOD; - GP_Font[','] = Char_COMMA; - GP_Font['='] = Char_EQUAL; - GP_Font['-'] = Char_MINUS; - GP_Font['+'] = Char_PLUS; - GP_Font['\"'] = Char_QUOTE; - GP_Font['('] = Char_LPAREN; - GP_Font[')'] = Char_RPAREN; - GP_Font[':'] = Char_COLON; - GP_Font['/'] = Char_SLASH; - GP_Font[' '] = Char_SPACE; - InitGP_Font = 1; -} - -/* ----------------------------------------------------------------------- - void FrameBuffer_drawchar(FrameBuffer *f, int x, int y, Pixel fgcolor, Pixel bgcolor, char chr, int orientation) - - Draws a character at location x, y with given color and orientation parameters. - Orientation can either be HORIZONTAL or VERTICAL - ----------------------------------------------------------------------- */ -void FrameBuffer_drawchar(FrameBuffer *f, int x, int y, int fgcolor, - int bgcolor, char chr, int orientation) { - - Pixel c, bc,*p,*p1; - char *ch; - int i,j; - int xpixels,ypixels; - - if (!InitGP_Font) initGP_Fonts(); - - c = (Pixel) fgcolor; - bc = (Pixel) bgcolor; - xpixels = f->width; - ypixels = f->height; - - if (orientation == HORIZONTAL) { - if ((x < f->xmin) || (x > f->xmax-8) || - (y < f->ymin) || (y > f->ymax-10)) return; - - ch = GP_Font[(int) chr]; - if (!ch) return; - p = &f->pixels[y+9][x]; - for (i = 0; i < 10; i++) { - p1 = p; - for (j = 0; j< 8; j++) { - if (*(ch++) == 'x') *p= c; - else if (bgcolor >= 0) - *p = bc; - p++; - } - p = (p1 - xpixels); - } - } else { - if ((x < f->xmin+10) || (x >= f->xmax) || - (y < f->ymin) || (y > f->ymax-8)) return; - - ch = GP_Font[(int) chr]; - if (!ch) return; - p = &f->pixels[y][x-9]; - for (i = 0; i < 10; i++) { - p1 = p; - for (j = 0; j< 8; j++) { - if (*(ch++) == 'x') *p= c; - else if (bgcolor >= 0) - *p = bc; - p+=xpixels; - } - p = p1 + 1; - } - } -} - -/* ---------------------------------------------------------------------- - void FrameBuffer_drawstring(FrameBuffer *f, int x, int y, int fgcolor, - int bgcolor, char *text, int orientation) - - Draws an ASCII string on the framebuffer. Can be oriented either horizontally - or vertically. - ---------------------------------------------------------------------- */ - -void FrameBuffer_drawstring(FrameBuffer *f, int x, int y, int fgcolor, int bgcolor, char *text, int orientation) { - - char *c; - int x1, y1; - int xpixels, ypixels; - - x1 = x; - y1 = y; - xpixels = f->width; - ypixels = f->height; - c = text; - while (*c) { - if (*c == '\n') { - if (orientation == HORIZONTAL) { - x1 = x; y1= y1- 10*xpixels; - } else { - y1 = y; x1= x1 + 10*ypixels; - } - } else { - FrameBuffer_drawchar(f, x1,y1,fgcolor, bgcolor,*c, orientation); - if (orientation == HORIZONTAL) { - x1+=8; - if (x1 >= (xpixels-8)) { - x1 = x; y1= y1- 10;} - if (y1 < 0) return; - } else { - y1 += 8; - if (y1 >= (ypixels-8)) { - y1 = y; x1 = x1 + 10;} - if (x1 > (xpixels-10)) return; - } - } - c++; - } -} - - - - - - - - diff --git a/Examples/GIFPlot/Lib/frame.c b/Examples/GIFPlot/Lib/frame.c deleted file mode 100644 index e006f0daf..000000000 --- a/Examples/GIFPlot/Lib/frame.c +++ /dev/null @@ -1,924 +0,0 @@ -/* ----------------------------------------------------------------------------- - * frame.c - * - * Frame buffer management - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define FRAME -#include "gifplot.h" -#include - -/* ------------------------------------------------------------------------ - FrameBuffer *new_FrameBuffer(int width, int height) - - Creates a new framebuffer for storing data. - ------------------------------------------------------------------------ */ - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height) { - - FrameBuffer *f; - int FrameBuffer_resize(FrameBuffer *f, int width, int height); - - /* Create a new frame buffer */ - - f = (FrameBuffer *) malloc(sizeof(FrameBuffer)); - f->pixels = (Pixel **) 0; - f->zbuffer = (Zvalue **) 0; - /* Set its size */ - - if (FrameBuffer_resize(f, width, height) == -1) { - free((char *) f); - return (FrameBuffer *) 0; - } - - f->xmin = 0; - f->ymin = 0; - f->xmax = width; - f->ymax = height; - return f; -} - -/* ------------------------------------------------------------------------ - void delete_FrameBuffer(FrameBuffer *f) - - Destroys the given framebuffer - ------------------------------------------------------------------------ */ - -void delete_FrameBuffer(FrameBuffer *f) { - - if (f) { - if (f->pixels) { - free((char *) f->pixels[0]); - free((char *) f->pixels); - } - if (f->zbuffer) { - free((char *) f->zbuffer[0]); - free((char *) f->zbuffer); - } - free((char *)f); - } -} - -/* ------------------------------------------------------------------------ - int *FrameBuffer_resize(FrameBuffer *f, int width, int height) - - Resize the given framebuffer. Returns 0 on success, -1 on failure. - ------------------------------------------------------------------------ */ - -int FrameBuffer_resize(FrameBuffer *f, int width, int height) { - int i; - if ((f) && (width > 0) && (height > 0)) { - if (f->pixels) { - free((char *)f->pixels[0]); - free((char *)f->pixels); - } - f->pixels = (Pixel **) malloc (height*sizeof(Pixel *)); - if (!f->pixels) return -1; - f->pixels[0] = (Pixel *) malloc(height*width*sizeof(Pixel)); - if (!f->pixels[0]) { - free((char *)f->pixels); - return -1; - } - for (i = 0; i < height; i++) - f->pixels[i] = f->pixels[0] + i*width; - f->width = width; - f->height = height; - if (f->zbuffer) { - FrameBuffer_zresize(f,width,height); - } - return 0; - } else { - return -1; - } -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_clear(FrameBuffer *f, Pixel color) - - Clears the current FrameBuffer - ------------------------------------------------------------------------ */ - -void FrameBuffer_clear(FrameBuffer *f, Pixel color) { - Pixel *p; - unsigned int i; - p = &f->pixels[0][0]; - - for (i = 0; i < f->width*f->height; i++, p++) - *p = color; -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_plot(FrameBuffer *f, int x1, int y1, Pixel color) - - Plots a point and does a bounds check. - ------------------------------------------------------------------------ */ - -void FrameBuffer_plot(FrameBuffer *f, int x1, int y1, Pixel color) { - - if ((x1 < f->xmin) || (x1 >= f->xmax) || (y1 < f->ymin) || (y1 >= f->ymax)) - return; - f->pixels[y1][x1] = color; - -} - -/* ------------------------------------------------------------------------ - FrameBuffer_horizontal(Framebuffer *f, int xmin, int xmax, int y, Pixel color) - - Draw a horizontal line (clipped) - ------------------------------------------------------------------------ */ - -void FrameBuffer_horizontal(FrameBuffer *f, int xmin, int xmax, int y, Pixel color) { - - Pixel *p; - int i; - - if ((y < f->ymin) || (y >= f->ymax)) return; - if (xmin < f->xmin) xmin = f->xmin; - if (xmax >= f->xmax) xmax = f->xmax - 1; - - p = &f->pixels[y][xmin]; - for (i = xmin; i <= xmax; i++, p++) - *p = color; - -} - -/* ------------------------------------------------------------------------ - FrameBuffer_horizontalinterp(Framebuffer *f, int xmin, int xmax, int y, - Pixel c1, Pixel c2) - - Draw a horizontal line (clipped) with color interpolation. - ------------------------------------------------------------------------ */ - -void FrameBuffer_horizontalinterp(FrameBuffer *f, int xmin, int xmax, int y, - Pixel c1, Pixel c2) { - - Pixel *p; - int i; - double mc; - int x1; - if ((y < f->ymin) || (y >= f->ymax)) return; - - x1 = xmin; - if (xmin < f->xmin) xmin = f->xmin; - if (xmax >= f->xmax) xmax = f->xmax - 1; - if (xmax < f->xmin) return; - if (xmin >= f->xmax) return; - - if (xmin != xmax) - mc = (double)(c2 - c1)/(double) (xmax - xmin); - else - mc = 0.0; - - p = &f->pixels[y][xmin]; - for (i = xmin; i <= xmax; i++, p++) - *p = (Pixel) (mc*(i-x1) + c1); - -} - - -/* ------------------------------------------------------------------------ - FrameBuffer_vertical(Framebuffer *f, int xmin, int xmax, int y, Pixel color) - - Draw a Vertical line (clipped) - ------------------------------------------------------------------------ */ - -void FrameBuffer_vertical(FrameBuffer *f, int ymin, int ymax, int x, Pixel color) { - - Pixel *p; - int i; - - if ((x < f->xmin) || (x >= f->xmax)) return; - if (ymax < f->ymin) return; - if (ymin > f->ymax) return; - if (ymin < f->ymin) ymin = f->ymin; - if (ymax >= f->ymax) ymax = f->ymax - 1; - - p = &f->pixels[ymin][x]; - for (i = 0; i <= (ymax - ymin); i++, p+=f->width) - *p = color; - -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_box(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel color) - - Makes an outline box. - ------------------------------------------------------------------------ */ - -void FrameBuffer_box(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel color) { - - int xt, yt; - - /* Make sure points are in correct order */ - - if (x2 < x1) { - xt = x2; - x2 = x1; - x1 = xt; - } - if (y2 < y1) { - yt = y2; - y2 = y1; - y1 = yt; - } - - /* Draw lower edge */ - - FrameBuffer_horizontal(f,x1,x2,y1,color); - - /* Draw upper edge */ - - FrameBuffer_horizontal(f,x1,x2,y2,color); - - /* Draw left side */ - - FrameBuffer_vertical(f,y1,y2,x1,color); - - /* Draw right side */ - - FrameBuffer_vertical(f,y1,y2,x2,color); - -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_solidbox(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel color) - - Makes an solid box. - ------------------------------------------------------------------------ */ - -void FrameBuffer_solidbox(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel color) { - - int xt, yt; - - /* Make sure points are in correct order */ - - if (x2 < x1) { - xt = x2; - x2 = x1; - x1 = xt; - } - if (y2 < y1) { - yt = y2; - y2 = y1; - y1 = yt; - } - - /* Now perform some clipping */ - - if (y1 < f->ymin) y1 = f->ymin; - if (y2 >= f->ymax) y2 = f->ymax - 1; - - /* Fill it in using horizontal lines */ - - for (yt = y1; yt <= y2; yt++) - FrameBuffer_horizontal(f,x1,x2,yt,color); - -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_interpbox(FrameBuffer *f, int x1, int y1, int x2, int y2 - Pixel c1, Pixel c2, Pixel c3, Pixel c4) - - Makes a box with interpolated color. Colors are assigned as follows : - (x1,y1) = c1 - (x1,y2) = c2 - (x2,y1) = c3 - (x2,y2) = c4 - ------------------------------------------------------------------------ */ - -void FrameBuffer_interpbox(FrameBuffer *f, int x1, int y1, int x2, int y2, - Pixel c1, Pixel c2, Pixel c3, Pixel c4) { - - int xt, yt; - Pixel ct; - double mc1,mc2; - int ystart; - /* Make sure points are in correct order */ - - if (x2 < x1) { - xt = x2; - x2 = x1; - x1 = xt; - ct = c1; - c1 = c3; - c3 = ct; - ct = c2; - c2 = c4; - c4 = ct; - } - if (y2 < y1) { - yt = y2; - y2 = y1; - y1 = yt; - ct = c1; - c1 = c2; - c2 = ct; - ct = c3; - c3 = c4; - c4 = ct; - } - - /* Now perform some clipping */ - - ystart = y1; - mc1 = (double) (c2 - c1)/(double) (y2 - y1); - mc2 = (double) (c4 - c3)/(double) (y2 - y1); - if (y1 < f->ymin) y1 = f->ymin; - if (y2 >= f->ymax) y2 = f->ymax - 1; - - /* Fill it in using horizontal lines */ - - for (yt = y1; yt <= y2; yt++) - FrameBuffer_horizontalinterp(f,x1,x2,yt,(Pixel) ((mc1*(yt - ystart)) + c1), - (Pixel) ((mc2*(yt-ystart))+c3)); - -} - -/* --------------------------------------------------------------------------- - FrameBuffer_line(FrameBuffer *f, int x1, int y1, int x2, int y2, color) - - Draws a line on the framebuffer using the Bresenham line algorithm. The - line is clipped to fit within the current view window. - ---------------------------------------------------------------------------- */ - -void FrameBuffer_line(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel c) { - - int dx,dy,dxneg,dyneg, inc1,inc2,di; - int x, y, xpixels, ypixels, xt, yt; - Pixel *p; - double m; - int end1 = 0, end2 = 0; - - /* Need to figure out where in the heck this line is */ - - dx = x2 - x1; - dy = y2 - y1; - - if (dx == 0) { - /* Draw a Vertical Line */ - if (y1 < y2) - FrameBuffer_vertical(f,y1,y2,x1,c); - else - FrameBuffer_vertical(f,y2,y1,x1,c); - return; - } - if (dy == 0) { - /* Draw a Horizontal Line */ - if (x1 < x2) - FrameBuffer_horizontal(f,x1,x2,y1,c); - else - FrameBuffer_horizontal(f,x2,x1,y1,c); - return; - } - - /* Figure out where in the heck these lines are using the - Cohen-Sutherland Line Clipping Scheme. */ - - end1 = ((x1 - f->xmin) < 0) | - (((f->xmax- 1 - x1) < 0) << 1) | - (((y1 - f->ymin) < 0) << 2) | - (((f->ymax-1 - y1) < 0) << 3); - - end2 = ((x2 - f->xmin) < 0) | - (((f->xmax-1 - x2) < 0) << 1) | - (((y2 - f->ymin) < 0) << 2) | - (((f->ymax-1 - y2) < 0) << 3); - - if (end1 & end2) return; /* Nope : Not visible */ - - /* Make sure points have a favorable orientation */ - - if (x1 > x2) { - xt = x1; - x1 = x2; - x2 = xt; - yt = y1; - y1 = y2; - y2 = yt; - } - - /* Clip against the boundaries */ - m = (y2 - y1)/(double) (x2-x1); - if (x1 < f->xmin) { - y1 = (int) ((f->xmin - x1)*m + y1); - x1 = (int) f->xmin; - } - if (x2 >= f->xmax) { - y2 = (int) ((f->xmax -1 -x1)*m + y1); - x2 = (int) (f->xmax - 1); - } - - if (y1 > y2) { - xt = x1; - x1 = x2; - x2 = xt; - yt = y1; - y1 = y2; - y2 = yt; - } - - m = 1/m; - if (y1 < f->ymin) { - x1 = (int) ((f->ymin - y1)*m + x1); - y1 = (int) f->ymin; - } - if (y2 >= f->ymax) { - x2 = (int) ((f->ymax-1-y1)*m + x1); - y2 = (int) (f->ymax-1); - } - - if ((x1 < f->xmin) || (x1 >= f->xmax) || (y1 < f->ymin) || (y1 >= f->ymax) || - (x2 < f->xmin) || (x2 >= f->xmax) || (y2 < f->ymin) || (y2 >= f->ymax)) return; - - dx = x2 - x1; - dy = y2 - y1; - xpixels = f->width; - ypixels = f->height; - - dxneg = (dx < 0) ? 1 : 0; - dyneg = (dy < 0) ? 1 : 0; - - dx = abs(dx); - dy = abs(dy); - if (dx >= dy) { - /* Slope between -1 and 1. */ - if (dxneg) { - x = x1; - y = y1; - x1 = x2; - y1 = y2; - x2 = x; - y2 = y; - dyneg = !dyneg; - } - inc1 = 2*dy; - inc2 = 2*(dy-dx); - di = 2*dy-dx; - - /* Draw a line using x as independent variable */ - - p = &f->pixels[y1][x1]; - x = x1; - while (x <= x2) { - *(p++) = c; - if (di < 0) { - di = di + inc1; - } else { - if (dyneg) { - p = p - xpixels; - di = di + inc2; - } else { - p = p + xpixels; - di = di + inc2; - } - } - x++; - } - } else { - /* Slope < -1 or > 1 */ - if (dyneg) { - x = x1; - y = y1; - x1 = x2; - y1 = y2; - x2 = x; - y2 = y; - dxneg = !dxneg; - } - inc1 = 2*dx; - inc2 = 2*(dx-dy); - di = 2*dx-dy; - - /* Draw a line using y as independent variable */ - - p = &f->pixels[y1][x1]; - y = y1; - while (y <= y2) { - *p = c; - p = p + xpixels; - if (di < 0) { - di = di + inc1; - } else { - if (dxneg) { - p = p - 1; - di = di + inc2; - } else { - p = p + 1; - di = di + inc2; - } - } - y++; - } - } -} - - -/* ------------------------------------------------------------------------- - FrameBuffer_circle(FrameBuffer f, int xc, int yc, int radius, Pixel c) - - Create an outline circle - ------------------------------------------------------------------------- */ - -#define plot_circle(x,y,c) \ - if ((x >= xmin) && (x < xmax) && \ - (y >= ymin) && (y < ymax)) \ - pixels[y][x] = c; - -void FrameBuffer_circle(FrameBuffer *f, int xc, int yc, int radius, Pixel c) { - - int xpixels, ypixels, x, y, p; - int xmin, ymin, xmax, ymax; - Pixel **pixels; - - if (radius <= 0) return; - xpixels = f->width; - ypixels = f->height; - pixels = f->pixels; - xmin = f->xmin; - ymin = f->ymin; - xmax = f->xmax; - ymax = f->ymax; - x = 0; - y = radius; - p = 3-2*radius; - while (x <= y) { - plot_circle(xc+x,yc+y,c); - plot_circle(xc-x,yc+y,c); - plot_circle(xc+x,yc-y,c); - plot_circle(xc-x,yc-y,c); - plot_circle(xc+y,yc+x,c); - plot_circle(xc-y,yc+x,c); - plot_circle(xc+y,yc-x,c); - plot_circle(xc-y,yc-x,c); - if (p < 0) p = p + 4*x + 6; - else { - p = p + 4*(x-y) + 10; - y = y -1; - } - x++; - } -} - - -/* ------------------------------------------------------------------------- - FrameBuffer_solidcircle(FrameBuffer f, int xc, int yc, int radius, Pixel c) - - Create an filled circle - ------------------------------------------------------------------------- */ - - -#define fill_circle(x,y,c) \ - x1 = xc - x; \ - x2 = xc + x; \ - FrameBuffer_horizontal(f,x1,x2,y,c); - -void FrameBuffer_solidcircle(FrameBuffer *f, int xc, int yc, int radius, Pixel c) { - - int xpixels, ypixels, x, y, p; - int x1,x2; - int xmin, ymin, xmax, ymax; - Pixel **pixels; - - if (radius <= 0) return; - xpixels = f->width; - ypixels = f->height; - pixels = f->pixels; - xmin = f->xmin; - ymin = f->ymin; - xmax = f->xmax; - ymax = f->ymax; - x = 0; - y = radius; - p = 3-2*radius; - while (x <= y) { - fill_circle(x,yc+y,c); - fill_circle(x,yc-y,c); - fill_circle(y,yc+x,c); - fill_circle(y,yc-x,c); - if (p < 0) p = p + 4*x + 6; - else { - p = p + 4*(x-y) + 10; - y = y -1; - } - x++; - } -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_setclip(f,xmin,ymin,xmax,ymax) - - Set clipping region for plotting - ------------------------------------------------------------------------ */ - -void FrameBuffer_setclip(FrameBuffer *f, int xmin, int ymin, int xmax, int ymax) { - - if (xmin >= xmax) return; - if (ymin >= ymax) return; - - if (xmin < 0) xmin = 0; - if (ymin < 0) ymin = 0; - if (xmax > (int) f->width) xmax = f->width; - if (ymax > (int) f->height) ymax = f->height; - - f->xmin = xmin; - f->ymin = ymin; - f->xmax = xmax; - f->ymax = ymax; -} - -/* ------------------------------------------------------------------------ - void FrameBuffer_noclip(f) - - Disable clipping region - ------------------------------------------------------------------------ */ - -void FrameBuffer_noclip(FrameBuffer *f) { - f->xmin = 0; - f->ymin = 0; - f->xmax = f->width; - f->ymax = f->height; -} - - -/* ------------------------------------------------------------------------ - FrameBuffer_zresize(FrameBuffer *f, int width, int height) - - This function resizes the framebuffer's zbuffer. If none exist, it - creates a new one. - ------------------------------------------------------------------------ */ - -void FrameBuffer_zresize(FrameBuffer *f, int width, int height) { - int i; - - if (f->zbuffer) { - free((char *)f->zbuffer[0]); - free((char *)f->zbuffer); - } - f->zbuffer = (Zvalue **) malloc(height*sizeof(Zvalue *)); - f->zbuffer[0] = (Zvalue *) malloc(height*width*sizeof(Zvalue)); - for (i = 0; i < height; i++) - f->zbuffer[i] = f->zbuffer[0]+i*width; -} - -/* ------------------------------------------------------------------------ - FrameBuffer_zclear(FrameBuffer *f) - - Clears the z-buffer for a particular frame. Sets all of the z-values to - ZMIN. - ------------------------------------------------------------------------- */ - -void FrameBuffer_zclear(FrameBuffer *f) { - unsigned int i,j; - if (f) { - if (f->zbuffer) { - for (i = 0; i < f->width; i++) - for (j = 0; j < f->height; j++) - f->zbuffer[j][i] = ZMIN; - } - } -} - - - -/* ------------------------------------------------------------------------- - FrameBuffer_solidtriangle(FrameBuffer *f, int tx1, int ty2, - int tx2, int ty2, - int tx3, int ty3, Pixel color) - - This function draws a 2D filled triangle. - - General idea : - 1. Transform the three points into screen coordinates - 2. Order three points vertically on screen. - 3. Check for degenerate cases (where 3 points are colinear). - 4. Fill in the resulting triangle using horizontal lines. - -------------------------------------------------------------------------- */ - -void FrameBuffer_solidtriangle(FrameBuffer *f, int tx1, int ty1, - int tx2, int ty2, - int tx3, int ty3, Pixel color) { - int tempx, tempy; - double m1,m2,m3; - int y; - int ix1, ix2; - - /* Figure out which point has the greatest "y" value */ - - if (ty2 > ty1) { /* Swap points 1 and 2 if 2 is higher */ - tempx = tx1; - tempy = ty1; - tx1 = tx2; - ty1 = ty2; - tx2 = tempx; - ty2 = tempy; - } - if (ty3 > ty1) { /* Swap points 1 and 3 if 3 is higher */ - tempx = tx1; - tempy = ty1; - tx1 = tx3; - ty1 = ty3; - tx3 = tempx; - ty3 = tempy; - } - if (ty3 > ty2) { /* Swap points 2 and 3 if 3 is higher */ - tempx = tx2; - tempy = ty2; - tx2 = tx3; - ty2 = ty3; - tx3 = tempx; - ty3 = tempy; - } - - /* Points are now order so that t_1 is the highest point, t_2 is the - middle point, and t_3 is the lowest point */ - - /* Check for degenerate cases here */ - - if ((ty1 == ty2) && (ty2 == ty3)) { - - /* Points are aligned horizontally. Handle as a special case */ - /* Just draw three lines using the outline color */ - - FrameBuffer_line(f,tx1,ty1,tx2,ty2,color); - FrameBuffer_line(f,tx1,ty1,tx3,ty3,color); - FrameBuffer_line(f,tx2,ty2,tx3,ty3,color); - - } else { - - if (ty2 < ty1) { - /* First process line segments between (x1,y1)-(x2,y2) - And between (x1,y1),(x3,y3) */ - - m1 = (double) (tx2 - tx1)/(double) (ty2 - ty1); - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - - y = ty1; - while (y >= ty2) { - /* Calculate x values from slope */ - ix1 = (int) (m1*(y-ty1)+0.5) + tx1; - ix2 = (int) (m2*(y-ty1)+0.5) + tx1; - if (ix1 > ix2) - FrameBuffer_horizontal(f,ix2,ix1,y,color); - else - FrameBuffer_horizontal(f,ix1,ix2,y,color); - y--; - } - } - if (ty3 < ty2) { - /* Draw lower half of the triangle */ - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - m3 = (double) (tx3 - tx2)/(double)(ty3 - ty2); - y = ty2; - while (y >= ty3) { - ix1 = (int) (m3*(y-ty2)+0.5)+tx2; - ix2 = (int) (m2*(y-ty1)+0.5)+tx1; - if (ix1 > ix2) - FrameBuffer_horizontal(f,ix2,ix1,y,color); - else - FrameBuffer_horizontal(f,ix1,ix2,y,color); - y--; - } - } - } -} - -/* ------------------------------------------------------------------------- - FrameBuffer_interptriangle(FrameBuffer *f, - int tx1, int ty2, Pixel c1, - int tx2, int ty2, Pixel c2, - int tx3, int ty3, Pixel c3) - - This function draws a filled triangle with color - interpolation. - - General idea : - 1. Transform the three points into screen coordinates - 2. Order three points vertically on screen. - 3. Check for degenerate cases (where 3 points are colinear). - 4. Fill in the resulting triangle using horizontal lines. - 5. Colors are interpolated between end points - -------------------------------------------------------------------------- */ - -void FrameBuffer_interptriangle(FrameBuffer *f, - int tx1, int ty1, Pixel c1, - int tx2, int ty2, Pixel c2, - int tx3, int ty3, Pixel c3) { - int tempx, tempy; - double m1,m2,m3; - double mc1,mc2,mc3; - Pixel ic1,ic2,tempc; - int y; - int ix1, ix2; - - /* Figure out which point has the greatest "y" value */ - - if (ty2 > ty1) { /* Swap points 1 and 2 if 2 is higher */ - tempx = tx1; - tempy = ty1; - tempc = c1; - tx1 = tx2; - ty1 = ty2; - c1 = c2; - tx2 = tempx; - ty2 = tempy; - c2 = tempc; - } - if (ty3 > ty1) { /* Swap points 1 and 3 if 3 is higher */ - tempx = tx1; - tempy = ty1; - tempc = c1; - tx1 = tx3; - ty1 = ty3; - c1 = c3; - tx3 = tempx; - ty3 = tempy; - c3 = tempc; - } - if (ty3 > ty2) { /* Swap points 2 and 3 if 3 is higher */ - tempx = tx2; - tempy = ty2; - tempc = c2; - tx2 = tx3; - ty2 = ty3; - c2 = c3; - tx3 = tempx; - ty3 = tempy; - c3 = tempc; - } - - /* Points are now order so that t_1 is the highest point, t_2 is the - middle point, and t_3 is the lowest point */ - - /* Check for degenerate cases here */ - - if ((ty1 == ty2) && (ty2 == ty3)) { - - /* Points are aligned horizontally. Handle as a special case */ - /* Just draw three lines using the outline color */ - - if (tx2 > tx1) - FrameBuffer_horizontalinterp(f,tx1,tx2,ty1,c1,c2); - else - FrameBuffer_horizontalinterp(f,tx2,tx1,ty1,c2,c1); - if (tx3 > tx1) - FrameBuffer_horizontalinterp(f,tx1,tx3,ty1,c1,c3); - else - FrameBuffer_horizontalinterp(f,tx3,tx1,ty1,c3,c1); - if (tx3 > tx2) - FrameBuffer_horizontalinterp(f,tx2,tx3,ty2,c2,c3); - else - FrameBuffer_horizontalinterp(f,tx3,tx2,ty2,c3,c2); - - } else { - - /* First process line segments between (x1,y1)-(x2,y2) - And between (x1,y1),(x3,y3) */ - - if (ty2 < ty1) { - m1 = (double) (tx2 - tx1)/(double) (ty2 - ty1); - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - mc1 = (c2 - c1)/(double) (ty2 - ty1); - mc2 = (c3 - c1)/(double) (ty3 - ty1); - - y = ty1; - while (y >= ty2) { - /* Calculate x values from slope */ - ix1 = (int) (m1*(y-ty1)+0.5) + tx1; - ix2 = (int) (m2*(y-ty1)+0.5) + tx1; - ic1 = (int) (mc1*(y-ty1) + c1); - ic2 = (int) (mc2*(y-ty1) + c1); - if (ix1 > ix2) - FrameBuffer_horizontalinterp(f,ix2,ix1,y,ic2,ic1); - else - FrameBuffer_horizontalinterp(f,ix1,ix2,y,ic1,ic2); - y--; - } - } - if (ty3 < ty2) { - /* Draw lower half of the triangle */ - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - mc2 = (c3 - c1)/(double) (ty3 - ty1); - m3 = (double) (tx3 - tx2)/(double)(ty3 - ty2); - mc3 = (c3 - c2)/(double) (ty3 - ty2); - y = ty2; - while (y >= ty3) { - ix1 = (int) (m3*(y-ty2)+0.5)+tx2; - ix2 = (int) (m2*(y-ty1)+0.5)+tx1; - ic1 = (int) (mc3*(y-ty2)+c2); - ic2 = (int) (mc2*(y-ty1)+c1); - if (ix1 > ix2) - FrameBuffer_horizontalinterp(f,ix2,ix1,y,ic2,ic1); - else - FrameBuffer_horizontalinterp(f,ix1,ix2,y,ic1,ic2); - y--; - } - } - } -} - - diff --git a/Examples/GIFPlot/Lib/gif.c b/Examples/GIFPlot/Lib/gif.c deleted file mode 100644 index 7953e5ce9..000000000 --- a/Examples/GIFPlot/Lib/gif.c +++ /dev/null @@ -1,672 +0,0 @@ - -/********************************************************************** - * GIFPlot 0.0 - * - * Dave Beazley - * - * Department of Computer Science Theoretical Division (T-11) - * University of Utah Los Alamos National Laboratory - * Salt Lake City, Utah 84112 Los Alamos, New Mexico 87545 - * beazley@cs.utah.edu beazley@lanl.gov - * - * Copyright (c) 1996 - * The Regents of the University of California and the University of Utah - * All Rights Reserved - * - * Permission is hereby granted, without written agreement and without - * license or royalty fees, to use, copy, modify, and distribute this - * software and its documentation for any purpose, provided that - * (1) The above copyright notice and the following two paragraphs - * appear in all copies of the source code and (2) redistributions - * including binaries reproduces these notices in the supporting - * documentation. Substantial modifications to this software may be - * copyrighted by their authors and need not follow the licensing terms - * described here, provided that the new terms are clearly indicated in - * all files where they apply. - * - * IN NO EVENT SHALL THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, THE - * UNIVERSITY OF UTAH OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY - * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL - * DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, - * EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - * - * THE AUTHOR, THE UNIVERSITY OF CALIFORNIA, AND THE UNIVERSITY OF UTAH - * SPECIFICALLY DISCLAIM ANY WARRANTIES,INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND - * THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, - * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - * - **************************************************************************/ - -/******************************************************************* - * Creates a GIF format file. - * - * Dave Beazley (T-11) - * August 11, 1995 - * - * Rather than writing directly to files, this module fills out - * output buffer. - * - * Note : To save memory, this routine uses approximately 50K of the - * output buffer as temporary storage (for hash tables and compression codes). - * The remainder of the output buffer is used to store the final image. - * This feature allows GIF images to be created with no additional - * memory overhead. - * - * -- Revision History - * $Log$ - * Revision 1.2 2003/09/01 16:23:31 beazley - * Restored the 'mojo'. - * - * Revision 1.2 1996/09/25 22:39:30 dmb - * Fixed prototypes and use of void pointers for compatibility with the Cray T3D - * - * Revision 1.1 1996/09/10 17:44:00 dmb - * Initial revision - * - * Revision 1.2 1995/08/31 14:46:07 beazley - * Minor changes to support comments and a few bug fixes. - * - * - ******************************************************************/ - - -/* - * xvgifwr.c - handles writing of GIF files. based on flgife.c and - * flgifc.c from the FBM Library, by Michael Maudlin - * - * Contains: - * WriteGIF(fp, pic, ptype, w, h, rmap, gmap, bmap, numcols, colorstyle, - * comment) - * - * Note: slightly brain-damaged, in that it'll only write non-interlaced - * GIF files (in the interests of speed, or something) - * - */ - - - -/***************************************************************** - * Portions of this code Copyright (C) 1989 by Michael Mauldin. - * Permission is granted to use this file in whole or in - * part for any purpose, educational, recreational or commercial, - * provided that this copyright notice is retained unchanged. - * This software is available to all free of charge by anonymous - * FTP and in the UUNET archives. - * - * - * Authors: Michael Mauldin (mlm@cs.cmu.edu) - * David Rowley (mgardi@watdcsu.waterloo.edu) - * - * Based on: compress.c - File compression ala IEEE Computer, June 1984. - * - * Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas) - * Jim McKie (decvax!mcvax!jim) - * Steve Davies (decvax!vax135!petsd!peora!srd) - * Ken Turkowski (decvax!decwrl!turtlevax!ken) - * James A. Woods (decvax!ihnp4!ames!jaw) - * Joe Orost (decvax!vax135!petsd!joe) - *****************************************************************/ - -#include "gifplot.h" -#include -typedef long int count_int; -typedef unsigned char byte; - -static int gif_error; -static unsigned char *op; -static int Width, Height; -static int curx, cury; -static int Interlace; - -static void putgifword(int); -static void compress(int, byte **, int); -static void output_GIF(int); -static void cl_block(void); -static void cl_hash(count_int); -static void char_init(void); -static void char_out(int); -static void flush_char(void); -static void *OutBuffer; -static int OutBufSize; -static FrameBuffer *GIF_frame; - -static unsigned char pc2nc[256],r1[256],g1[256],b1[256]; - -/*************************************************************/ -int FrameBuffer_makeGIF(FrameBuffer *f, ColorMap *c, void *outbuffer, unsigned int outbufsize) -{ - int RWidth, RHeight; - int LeftOfs, TopOfs; - int ColorMapSize, InitCodeSize, Background, BitsPerPixel; - int i,j,nc; - char *rmap, *gmap, *bmap; - char *cmap; - int count; - - Interlace = 0; - Background = 0; - OutBuffer = outbuffer; - OutBufSize = outbufsize; - GIF_frame = f; - cmap = (char *) c->cmap; - - op = (unsigned char *) outbuffer; - gif_error = 0; - for (i=0; i<256; i++) { pc2nc[i] = r1[i] = g1[i] = b1[i] = 0; } - - /* compute number of unique colors */ - nc = 0; - rmap = &cmap[0]; - gmap = &cmap[256]; - bmap = &cmap[512]; - - for (i=0; i<256; i++) { - /* see if color #i is already used */ - for (j=0; j= nc) break; - - BitsPerPixel = i; - - ColorMapSize = 1 << BitsPerPixel; - - RWidth = Width = f->width; - RHeight = Height = f->height; - LeftOfs = TopOfs = 0; - - if (BitsPerPixel <= 1) InitCodeSize = 2; - else InitCodeSize = BitsPerPixel; - - curx = 0; - cury = f->height - 1; - - strcpy((char *) op,"GIF89a"); /* Put in GIF magic number */ - op+=6; - putgifword(RWidth); /* screen descriptor */ - putgifword(RHeight); - - i = 0x80; /* Yes, there is a color map */ - i |= (8-1)<<4; /* OR in the color resolution (hardwired 8) */ - i |= (BitsPerPixel - 1); /* OR in the # of bits per pixel */ - *(op++) = i; - *(op++) = Background; /* background color */ - *(op++) = 0; - for (i=0; ipixels, f->width*f->height); - - *(op++) = 0; - *(op++) = ';'; - - count = (op - (unsigned char *) OutBuffer); - if (gif_error) return -1; - else return count; -} - -/******************************/ -static void putgifword(w) -int w; -{ - /* writes a 16-bit integer in GIF order (LSB first) */ - *(op++) = w & 0xff; - *(op++) = (w>>8)&0xff; -} - -/***********************************************************************/ - - -static unsigned long cur_accum = 0; -static int cur_bits = 0; - - - - -#define GP_BITS 12 /* BITS was already defined on some systems */ - -#define HSIZE 5003 /* 80% occupancy */ - -typedef unsigned char char_type; - -static int n_bits; /* number of bits/code */ -static int maxbits = GP_BITS; /* user settable max # bits/code */ -static int maxcode; /* maximum code, given n_bits */ -static int maxmaxcode = 1 << GP_BITS; /* NEVER generate this */ - -#define MAXCODE(n_bits) ( (1 << (n_bits)) - 1) - -static count_int *htab; -static unsigned short *codetab; -static int GIFOutBufSize; - -/* static count_int htab [HSIZE]; -static unsigned short codetab [HSIZE]; */ - -#define HashTabOf(i) htab[i] -#define CodeTabOf(i) codetab[i] - -static int hsize = HSIZE; /* for dynamic table sizing */ - -/* - * To save much memory, we overlay the table used by compress() with those - * used by decompress(). The tab_prefix table is the same size and type - * as the codetab. The tab_suffix table needs 2**BITS characters. We - * get this from the beginning of htab. The output stack uses the rest - * of htab, and contains characters. There is plenty of room for any - * possible stack (stack used to be 8000 characters). - */ - -#define tab_prefixof(i) CodeTabOf(i) -#define tab_suffixof(i) ((char_type *)(htab))[i] -#define de_stack ((char_type *)&tab_suffixof(1<= GIF_frame->width) { - curx = 0; - cury--; - } - len--; - - hshift = 0; - for ( fcode = (long) hsize; fcode < 65536L; fcode *= 2L ) - hshift++; - hshift = 8 - hshift; /* set hash code range bound */ - - hsize_reg = hsize; - cl_hash( (count_int) hsize_reg); /* clear hash table */ - - output_GIF(ClearCode); - while (len) { - c = pc2nc[data[cury][curx]]; - curx++; - if (curx >= GIF_frame->width) { - curx = 0; - cury--; - } - len--; - - fcode = (long) ( ( (long) c << maxbits) + ent); - i = (((int) c << hshift) ^ ent); /* xor hashing */ - - if ( HashTabOf (i) == fcode ) { - ent = CodeTabOf (i); - continue; - } - - if ( (long)HashTabOf (i) < 0 ) /* empty slot */ - goto nomatch; - - disp = hsize_reg - i; /* secondary hash (after G. Knott) */ - if ( i == 0 ) - disp = 1; - -probe: - if ( (i -= disp) < 0 ) - i += hsize_reg; - - if ( HashTabOf (i) == fcode ) { - ent = CodeTabOf (i); - continue; - } - - if ( (long)HashTabOf (i) >= 0 ) - goto probe; - -nomatch: - output_GIF(ent); - out_count++; - ent = c; - - if ( free_ent < maxmaxcode ) { - CodeTabOf (i) = free_ent++; /* code -> hashtable */ - HashTabOf (i) = fcode; - } - else - cl_block(); - - } - /* Put out the final code */ - output_GIF(ent); - output_GIF(EOFCode); -} - - -/***************************************************************** - * TAG( output_GIF ) - * - * Output the given code. - * Inputs: - * code: A n_bits-bit integer. If == -1, then EOF. This assumes - * that n_bits =< (long)wordsize - 1. - * Outputs: - * Outputs code to the file. - * Assumptions: - * Chars are 8 bits long. - * Algorithm: - * Maintain a BITS character long buffer (so that 8 codes will - * fit in it exactly). Use the VAX insv instruction to insert each - * code in turn. When the buffer fills up empty it and start over. - */ - -static -unsigned long masks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, - 0x001F, 0x003F, 0x007F, 0x00FF, - 0x01FF, 0x03FF, 0x07FF, 0x0FFF, - 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF }; - -static void output_GIF(code) -int code; -{ - cur_accum &= masks[cur_bits]; - - if (cur_bits > 0) - cur_accum |= ((long)code << cur_bits); - else - cur_accum = code; - - cur_bits += n_bits; - - while( cur_bits >= 8 ) { - char_out( (int) (cur_accum & 0xff) ); - cur_accum >>= 8; - cur_bits -= 8; - } - - /* - * If the next entry is going to be too big for the code size, - * then increase it, if possible. - */ - - if (free_ent > maxcode || clear_flg) { - - if( clear_flg ) { - maxcode = MAXCODE (n_bits = g_init_bits); - clear_flg = 0; - } - else { - n_bits++; - if ( n_bits == maxbits ) - maxcode = maxmaxcode; - else - maxcode = MAXCODE(n_bits); - } - } - - if( code == EOFCode ) { - /* At EOF, write the rest of the buffer */ - while( cur_bits > 0 ) { - char_out( (int)(cur_accum & 0xff) ); - cur_accum >>= 8; - cur_bits -= 8; - } - - flush_char(); - } -} - - -/********************************/ -static void cl_block () /* table clear for block compress */ -{ - /* Clear out the hash table */ - - cl_hash ( (count_int) hsize ); - free_ent = ClearCode + 2; - clear_flg = 1; - - output_GIF(ClearCode); -} - - -/********************************/ -static void cl_hash(hsize) /* reset code table */ -register count_int hsize; -{ - register count_int *htab_p = htab+hsize; - register long i; - register long m1 = -1; - - i = hsize - 16; - do { /* might use Sys V memset(3) here */ - *(htab_p-16) = m1; - *(htab_p-15) = m1; - *(htab_p-14) = m1; - *(htab_p-13) = m1; - *(htab_p-12) = m1; - *(htab_p-11) = m1; - *(htab_p-10) = m1; - *(htab_p-9) = m1; - *(htab_p-8) = m1; - *(htab_p-7) = m1; - *(htab_p-6) = m1; - *(htab_p-5) = m1; - *(htab_p-4) = m1; - *(htab_p-3) = m1; - *(htab_p-2) = m1; - *(htab_p-1) = m1; - htab_p -= 16; - } while ((i -= 16) >= 0); - - for ( i += 16; i > 0; i-- ) - *--htab_p = m1; -} - - -/****************************************************************************** - * - * GIF Specific routines - * - ******************************************************************************/ - -/* - * Number of characters so far in this 'packet' - */ -static int a_count; - -/* - * Set up the 'byte output' routine - */ -static void char_init() -{ - a_count = 0; -} - -/* - * Define the storage for the packet accumulator - */ -static char accum[ 256 ]; - -/* - * Add a character to the end of the current packet, and if it is 254 - * characters, flush the packet to disk. - */ -static void char_out(c) -int c; -{ - accum[ a_count++ ] = c; - if( a_count >= 254 ) - flush_char(); -} - -/* - * Flush the packet to disk, and reset the accumulator - */ -static void flush_char() -{ - if (gif_error) return; - if( a_count > 0 ) { - *(op++) = a_count; - memcpy(op,accum,a_count); - op+=a_count; - a_count = 0; - - if (op > (unsigned char *) ((char *) OutBuffer + (GIFOutBufSize - 2048))) { - gif_error = 1; - } - } -} - - -/* ---------------------------------------------------------------------- - int FrameBuffer_writeGIF(char *filename) - - Write a GIF file to filename - ----------------------------------------------------------------------- */ - -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename) { - - FILE *file; - void *buffer; - int nbytes; - int bufsize; - - file = fopen(filename,"wb"); - if (file == NULL) return -1; - - bufsize = (f->width*f->height*3)/2; - buffer = (void *) malloc(bufsize); - nbytes = FrameBuffer_makeGIF(f,c,buffer,bufsize); - if (nbytes == -1) { - free(buffer); - fclose(file); - return -1; - } - if (fwrite(buffer,nbytes,1,file) != 1) { - free(buffer); - fclose(file); - return -1; - } - fclose(file); - free(buffer); - return 0; -} - - - - - diff --git a/Examples/GIFPlot/Lib/matrix.c b/Examples/GIFPlot/Lib/matrix.c deleted file mode 100644 index ef0cf3aab..000000000 --- a/Examples/GIFPlot/Lib/matrix.c +++ /dev/null @@ -1,343 +0,0 @@ -/* ----------------------------------------------------------------------------- - * matrix.c - * - * Some 4x4 matrix operations - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define MATRIX -#include "gifplot.h" -#include - -/* ------------------------------------------------------------------------ - Matrix new_Matrix() - - Create a new 4x4 matrix. - ------------------------------------------------------------------------ */ -Matrix -new_Matrix() { - Matrix m; - m = (Matrix) malloc(16*sizeof(double)); - return m; -} - -/* ------------------------------------------------------------------------ - delete_Matrix(Matrix *m); - - Destroy a matrix - ------------------------------------------------------------------------ */ - -void -delete_Matrix(Matrix m) { - if (m) - free((char *) m); -} - -/* ------------------------------------------------------------------------ - Matrix Matrix_copy(Matrix a) - - Makes a copy of matrix a and returns it. - ------------------------------------------------------------------------ */ - -Matrix Matrix_copy(Matrix a) { - int i; - Matrix r = 0; - if (a) { - r = new_Matrix(); - if (r) { - for (i = 0; i < 16; i++) - r[i] = a[i]; - } - } - return r; -} - -/* ------------------------------------------------------------------------ - Matrix_multiply(Matrix a, Matrix b, Matrix c) - - Multiplies a*b = c - c may be one of the source matrices - ------------------------------------------------------------------------ */ -void -Matrix_multiply(Matrix a, Matrix b, Matrix c) { - double temp[16]; - int i,j,k; - - for (i =0; i < 4; i++) - for (j = 0; j < 4; j++) { - temp[i*4+j] = 0.0; - for (k = 0; k < 4; k++) - temp[i*4+j] += a[i*4+k]*b[k*4+j]; - } - for (i = 0; i < 16; i++) - c[i] = temp[i]; -} - -/* ------------------------------------------------------------------------ - Matrix_identity(Matrix a) - - Puts an identity matrix in matrix a - ------------------------------------------------------------------------ */ - -void -Matrix_identity(Matrix a) { - int i; - for (i = 0; i < 16; i++) a[i] = 0; - a[0] = 1; - a[5] = 1; - a[10] = 1; - a[15] = 1; -} - -/* ------------------------------------------------------------------------ - Matrix_zero(Matrix a) - - Puts a zero matrix in matrix a - ------------------------------------------------------------------------ */ -void -Matrix_zero(Matrix a) { - int i; - for (i = 0; i < 16; i++) a[i] = 0; -} - -/* ------------------------------------------------------------------------ - Matrix_transpose(Matrix a, Matrix result) - - Transposes matrix a and puts it in result. - ------------------------------------------------------------------------ */ -void -Matrix_transpose(Matrix a, Matrix result) { - double temp[16]; - int i,j; - - for (i = 0; i < 4; i++) - for (j = 0; j < 4; j++) - temp[4*i+j] = a[4*j+i]; - - for (i = 0; i < 16; i++) - result[i] = temp[i]; -} - - -/* ------------------------------------------------------------------------ - Matrix_gauss(Matrix a, Matrix b) - - Solves ax=b for x, using Gaussian elimination. Destroys a. - Really only used for calculating inverses of 4x4 transformation - matrices. - ------------------------------------------------------------------------ */ - -void Matrix_gauss(Matrix a, Matrix b) { - int ipiv[4], indxr[4], indxc[4]; - int i,j,k,l,ll; - int irow=0, icol=0; - double big, pivinv; - double dum; - for (j = 0; j < 4; j++) - ipiv[j] = 0; - for (i = 0; i < 4; i++) { - big = 0; - for (j = 0; j < 4; j++) { - if (ipiv[j] != 1) { - for (k = 0; k < 4; k++) { - if (ipiv[k] == 0) { - if (fabs(a[4*j+k]) >= big) { - big = fabs(a[4*j+k]); - irow = j; - icol = k; - } - } else if (ipiv[k] > 1) - return; /* Singular matrix */ - } - } - } - ipiv[icol] = ipiv[icol]+1; - if (irow != icol) { - for (l = 0; l < 4; l++) { - dum = a[4*irow+l]; - a[4*irow+l] = a[4*icol+l]; - a[4*icol+l] = dum; - } - for (l = 0; l < 4; l++) { - dum = b[4*irow+l]; - b[4*irow+l] = b[4*icol+l]; - b[4*icol+l] = dum; - } - } - indxr[i] = irow; - indxc[i] = icol; - if (a[4*icol+icol] == 0) return; - pivinv = 1.0/a[4*icol+icol]; - a[4*icol+icol] = 1.0; - for (l = 0; l < 4; l++) - a[4*icol+l] = a[4*icol+l]*pivinv; - for (l = 0; l < 4; l++) - b[4*icol+l] = b[4*icol+l]*pivinv; - for (ll = 0; ll < 4; ll++) { - if (ll != icol) { - dum = a[4*ll+icol]; - a[4*ll+icol] = 0; - for (l = 0; l < 4; l++) - a[4*ll+l] = a[4*ll+l] - a[4*icol+l]*dum; - for (l = 0; l < 4; l++) - b[4*ll+l] = b[4*ll+l] - b[4*icol+l]*dum; - } - } - } - for (l = 3; l >= 0; l--) { - if (indxr[l] != indxc[l]) { - for (k = 0; k < 4; k++) { - dum = a[4*k+indxr[l]]; - a[4*k+indxr[l]] = a[4*k+indxc[l]]; - a[4*k+indxc[l]] = dum; - } - } - } -} - -/* ------------------------------------------------------------------------ - Matrix_invert(Matrix a, Matrix inva) - - Inverts Matrix a and places the result in inva. - Relies on the Gaussian Elimination code above. (See Numerical recipes). - ------------------------------------------------------------------------ */ -void -Matrix_invert(Matrix a, Matrix inva) { - - double temp[16]; - int i; - - for (i = 0; i < 16; i++) - temp[i] = a[i]; - Matrix_identity(inva); - Matrix_gauss(temp,inva); -} - -/* ------------------------------------------------------------------------ - Matrix_transform(Matrix a, GL_Vector *r, GL_Vector *t) - - Transform a vector. a*r ----> t - ------------------------------------------------------------------------ */ - -void Matrix_transform(Matrix a, GL_Vector *r, GL_Vector *t) { - - double rx, ry, rz, rw; - - rx = r->x; - ry = r->y; - rz = r->z; - rw = r->w; - t->x = a[0]*rx + a[1]*ry + a[2]*rz + a[3]*rw; - t->y = a[4]*rx + a[5]*ry + a[6]*rz + a[7]*rw; - t->z = a[8]*rx + a[9]*ry + a[10]*rz + a[11]*rw; - t->w = a[12]*rx + a[13]*ry + a[14]*rz + a[15]*rw; -} - -/* ------------------------------------------------------------------------ - Matrix_transform4(Matrix a, double x, double y, double z, double w, GL_Vector *t) - - Transform a vector from a point specified as 4 doubles - ------------------------------------------------------------------------ */ - -void Matrix_transform4(Matrix a, double rx, double ry, double rz, double rw, - GL_Vector *t) { - - t->x = a[0]*rx + a[1]*ry + a[2]*rz + a[3]*rw; - t->y = a[4]*rx + a[5]*ry + a[6]*rz + a[7]*rw; - t->z = a[8]*rx + a[9]*ry + a[10]*rz + a[11]*rw; - t->w = a[12]*rx + a[13]*ry + a[14]*rz + a[15]*rw; -} - -/* --------------------------------------------------------------------- - Matrix_translate(Matrix a, double tx, double ty, double tz) - - Put a translation matrix in Matrix a - ---------------------------------------------------------------------- */ - -void Matrix_translate(Matrix a, double tx, double ty, double tz) { - Matrix_identity(a); - a[3] = tx; - a[7] = ty; - a[11] = tz; - a[15] = 1; -} - -/* ----------------------------------------------------------------------- - Matrix_rotatex(Matrix a, double deg) - - Produce an x-rotation matrix for given angle in degrees. - ----------------------------------------------------------------------- */ -void -Matrix_rotatex(Matrix a, double deg) { - double r; - - r = 3.1415926*deg/180.0; - Matrix_zero(a); - a[0] = 1.0; - a[5] = cos(r); - a[6] = -sin(r); - a[9] = sin(r); - a[10] = cos(r); - a[15] = 1.0; -} - -/* ----------------------------------------------------------------------- - Matrix_rotatey(Matrix a, double deg) - - Produce an y-rotation matrix for given angle in degrees. - ----------------------------------------------------------------------- */ -void -Matrix_rotatey(Matrix a, double deg) { - double r; - - r = 3.1415926*deg/180.0; - Matrix_zero(a); - a[0] = cos(r); - a[2] = sin(r); - a[5] = 1.0; - a[8] = -sin(r); - a[10] = cos(r); - a[15] = 1; - -} -/* ----------------------------------------------------------------------- - Matrix_RotateZ(Matrix a, double deg) - - Produce an z-rotation matrix for given angle in degrees. - ----------------------------------------------------------------------- */ -void -Matrix_rotatez(Matrix a, double deg) { - double r; - - r = 3.1415926*deg/180.0; - Matrix_zero(a); - a[0] = cos(r); - a[1] = -sin(r); - a[4] = sin(r); - a[5] = cos(r); - a[10] = 1.0; - a[15] = 1.0; -} - - -/* A debugging routine */ - -void Matrix_set(Matrix a, int i, int j, double val) { - a[4*j+i] = val; -} - -void Matrix_print(Matrix a) { - int i,j; - for (i = 0; i < 4; i++) { - for (j = 0; j < 4; j++) { - fprintf(stdout,"%10f ",a[4*i+j]); - } - fprintf(stdout,"\n"); - } - fprintf(stdout,"\n"); -} - diff --git a/Examples/GIFPlot/Lib/pixmap.c b/Examples/GIFPlot/Lib/pixmap.c deleted file mode 100644 index a55cf041f..000000000 --- a/Examples/GIFPlot/Lib/pixmap.c +++ /dev/null @@ -1,159 +0,0 @@ -/* ----------------------------------------------------------------------------- - * pixmap.c - * - * Pixel maps (i.e., bitmaps) - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define PIXMAP -#include "gifplot.h" - -/* ----------------------------------------------------------------------- - PixMap *new_PixMap(int width, int height, int centerx, int centery) - - Create a new pixmap of given size - ----------------------------------------------------------------------- */ -PixMap *new_PixMap(int width, int height, int centerx, int centery) { - PixMap *pm; - if ((width > 0) && (height > 0)) { - pm = (PixMap *) malloc(sizeof(PixMap)); - pm->width = width; - pm->height = height; - pm->centerx = centerx; - pm->centery = centery; - pm->map = (int *) malloc(height*width*sizeof(int)); - return pm; - } - return (PixMap *) 0; -} - -/* -------------------------------------------------------------------------- - void delete_PixMap(PixMap *pm) - - Destroy a pixmap - -------------------------------------------------------------------------- */ - -void delete_PixMap(PixMap *pm) { - if (pm) { - free((char *) pm->map); - free((char *) pm); - } -} - -/* --------------------------------------------------------------------------- - void PixMap_set(PixMap *pm, int x, int y, int pix) - - Set a pixel in the bitmap - --------------------------------------------------------------------------- */ -void -PixMap_set(PixMap *pm, int x, int y, int pix) { - if ((x < 0) || (x>=pm->width)) return; - if ((y < 0) || (y>=pm->height)) return; - - pm->map[pm->width*y + x] = pix; -} - -/* ----------------------------------------------------------------------------- - void FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor) - - Draw a pixmap onto the framebuffer. This is somewhat optimized for speed. - ------------------------------------------------------------------------------ */ - -void -FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor) { - - int startx, starty; /* Starting location on framebuffer */ - int startpixx = 0, startpixy = 0; /* Starting location in pixmap */ - int endx, endy; /* Ending location on framebuffer */ - int i,j, px, py; - int c; - - startx = x - pm->centerx; - starty = y + pm->centery; - endx = startx + pm->width; - endy = starty - pm->height; - - /* Figure out if we need to clip */ - - if (startx < f->xmin) { - startpixx = f->xmin - startx; - startx = f->xmin; - } - if (starty >= f->ymax) { - startpixy = starty - f->ymax; - starty = f->ymax-1; - } - if (endx >= f->xmax) { - endx = f->xmax-1; - } - if (endy < f->ymin) { - endy = f->ymin; - } - py = startpixy; - for (j = starty; j >= endy; j--) { - px = startpixx; - for (i = startx; i < endx; i++) { - c = pm->map[py*pm->width + px]; - switch (c) { - case GIFPLOT_FOREGROUND: - f->pixels[j][i] = fgcolor; - break; - case GIFPLOT_BACKGROUND: - f->pixels[j][i] = bgcolor; - break; - default: - break; - } - px++; - } - py++; - } -} - -/************************************************************************** - * Some common PixMaps (for plotting) - * - **************************************************************************/ - -int _SQUARE_MAP[] = { - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,1,1,1,1,1,1,1, - 0,0,0,0,0,0,0,0 }; - -PixMap PixMap_SQUARE = { 8,8,4,4, _SQUARE_MAP}; - -int _TRIANGLE_MAP[] = { - 0,0,0,1,0,0,0,0, - 0,0,0,1,0,0,0,0, - 0,0,1,1,1,0,0,0, - 0,0,1,1,1,0,0,0, - 0,1,1,1,1,1,0,0, - 0,1,1,1,1,1,0,0, - 1,1,1,1,1,1,1,0, - 0,0,0,0,0,0,0,0 }; - -PixMap PixMap_TRIANGLE = { 8,8,4,4,_TRIANGLE_MAP}; - -int _CROSS_MAP[] = { - 0,0,0,1,0,0,0,0, - 0,0,0,1,0,0,0,0, - 0,0,0,1,0,0,0,0, - 1,1,1,1,1,1,1,0, - 0,0,0,1,0,0,0,0, - 0,0,0,1,0,0,0,0, - 0,0,0,1,0,0,0,0, - 0,0,0,0,0,0,0,0 }; - -PixMap PixMap_CROSS = { 8,8,4,4,_CROSS_MAP}; - - - diff --git a/Examples/GIFPlot/Lib/plot2d.c b/Examples/GIFPlot/Lib/plot2d.c deleted file mode 100644 index e78107bf1..000000000 --- a/Examples/GIFPlot/Lib/plot2d.c +++ /dev/null @@ -1,445 +0,0 @@ -/* ----------------------------------------------------------------------------- - * plot2d.c - * - * 2-Dimensional plotting - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define PLOT2D - -#include "gifplot.h" - -/* ------------------------------------------------------------------------ - Plot2D *new_Plot2D(FrameBuffer *frame, xmin, ymin, xmax, ymax) - - Create a new 2D plot with given minimum and maximum coordinates. - ------------------------------------------------------------------------ */ -Plot2D *new_Plot2D(FrameBuffer *frame,double xmin,double ymin,double xmax,double ymax) { - Plot2D *p2; - if (frame) { - if (xmax <= xmin) return (Plot2D *) 0; - if (ymax <= ymin) return (Plot2D *) 0; - p2 = (Plot2D *) malloc(sizeof(Plot2D)); - p2->frame = frame; - p2->xmin = xmin; - p2->ymin = ymin; - p2->xmax = xmax; - p2->ymax = ymax; - p2->view_xmin = 0; - p2->view_xmax = frame->width; - p2->view_ymin = 0; - p2->view_ymax = frame->height; - p2->xscale = LINEAR; - p2->yscale = LINEAR; - p2->dx = (p2->view_xmax - p2->view_xmin)/(p2->xmax - p2->xmin); - p2->dy = (p2->view_ymax - p2->view_ymin)/(p2->ymax - p2->ymin); - return p2; - } - return (Plot2D *) 0; -} - -/* ---------------------------------------------------------------------------- - delete_Plot2D(Plot2D *p2) - - Delete a 2D plot - ---------------------------------------------------------------------------- */ -void -delete_Plot2D(Plot2D *p2) { - if (p2) - free((char *) p2); -} - -/* ----------------------------------------------------------------------------- - Plot2D *Plot2D_copy(Plot2D *p2) - - Makes a copy of the Plot2D data structure. - ----------------------------------------------------------------------------- */ - -Plot2D *Plot2D_copy(Plot2D *p2) { - Plot2D *c2; - if (p2) { - c2 = (Plot2D *) malloc(sizeof(Plot2D)); - if (c2) { - c2->frame = p2->frame; - c2->view_xmin = p2->view_xmin; - c2->view_ymin = p2->view_ymin; - c2->view_xmax = p2->view_xmax; - c2->view_ymax = p2->view_ymax; - c2->xmin = p2->xmin; - c2->ymin = p2->ymin; - c2->xmax = p2->xmax; - c2->ymax = p2->ymax; - c2->xscale = p2->xscale; - c2->yscale = p2->yscale; - c2->dx = p2->dx; - c2->dy = p2->dy; - } - return c2; - } else { - return (Plot2D *) 0; - } -} - -/* ----------------------------------------------------------------------------- - Plot2D_clear(Plot2D *p2, Pixel c) - - Clear the region assigned to this plot to the given color. - -------------------------------------------------------------------------- */ - -void Plot2D_clear(Plot2D *p2, Pixel c) { - int i,j; - for (i = p2->view_xmin; i < p2->view_xmax; i++) - for (j = p2->view_ymin; j < p2->view_ymax; j++) { - p2->frame->pixels[j][i] = c; - } -} - -/* ------------------------------------------------------------------------------ - Plot2D_setview - - Sets the plot region on the framebuffer - ------------------------------------------------------------------------------ */ - -void -Plot2D_setview(Plot2D *p2, int vxmin, int vymin, int vxmax, int vymax) { - if (p2) { - p2->view_xmin = vxmin; - p2->view_ymin = vymin; - p2->view_xmax = vxmax; - p2->view_ymax = vymax; - p2->dx = (p2->view_xmax - p2->view_xmin)/(p2->xmax - p2->xmin); - p2->dy = (p2->view_ymax - p2->view_ymin)/(p2->ymax - p2->ymin); - FrameBuffer_setclip(p2->frame,vxmin,vymin,vxmax,vymax); - } -} - -/* ------------------------------------------------------------------------------- - Plot2D_setrange(Plot2D *p2, double xmin, double ymin, double xmax, double ymax) - - Sets the plotting range. - ------------------------------------------------------------------------------- */ - -void -Plot2D_setrange(Plot2D *p2, double xmin, double ymin, double xmax, double ymax) { - if (p2) { - p2->xmin = xmin; - p2->ymin = ymin; - p2->xmax = xmax; - p2->ymax = ymax; - p2->dx = (p2->view_xmax - p2->view_xmin)/(p2->xmax - p2->xmin); - p2->dy = (p2->view_ymax - p2->view_ymin)/(p2->ymax - p2->ymin); - } -} - -/* ------------------------------------------------------------------------------- - Plot2D_setscale(Plot2D *p2, int xscale, int yscale) - - Sets the plotting scaling method - ------------------------------------------------------------------------------- */ - -void -Plot2D_setscale(Plot2D *p2, int xscale, int yscale) { - if (p2) { - p2->xscale = xscale; - p2->yscale = yscale; - } -} - -/* ---------------------------------------------------------------------------- - Plot2D_transform(Plot2D *p2, double x, double y, int *px, int *py) - - Transforms x,y into screen coordinates px and py. Result is returned - in px and py. Rounds to the nearest pixel instead of truncating. - ----------------------------------------------------------------------------- */ - -void -Plot2D_transform(Plot2D *p2, double x, double y, int *px, int *py) { - if (p2) { - *px = p2->view_xmin + (int) (p2->dx*(x-p2->xmin) + 0.5); - *py = p2->view_ymin + (int) (p2->dy*(y-p2->ymin) + 0.5); - } -} - -/* ------------------------------------------------------------------------------- - Plot2D_plot(Plot2D *p2, double x, double y, Pixel color) - - Plot a 2D Point of a given color - ------------------------------------------------------------------------------- */ -void -Plot2D_plot(Plot2D *p2, double x, double y, Pixel color) { - int px, py; - - Plot2D_transform(p2,x,y,&px,&py); - FrameBuffer_plot(p2->frame, px, py, color); -} - -/* ------------------------------------------------------------------------------- - Plot2D_box(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel Color) - - Plot an outline box on the 2D plot - ------------------------------------------------------------------------------- */ -void -Plot2D_box(Plot2D *p2, double x1, double y1,double x2, double y2, Pixel color) { - int ix1, ix2,iy1, iy2; - - Plot2D_transform(p2,x1,y1,&ix1,&iy1); - Plot2D_transform(p2,x2,y2,&ix2,&iy2); - FrameBuffer_box(p2->frame,ix1,iy1,ix2,iy2,color); -} - -/* ------------------------------------------------------------------------------- - Plot2D_solidbox(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel Color) - - Plot a solid box box on the 2D plot - ------------------------------------------------------------------------------- */ -void -Plot2D_solidbox(Plot2D *p2, double x1, double y1,double x2, double y2, Pixel color) { - int ix1, ix2,iy1, iy2; - - Plot2D_transform(p2,x1,y1,&ix1,&iy1); - Plot2D_transform(p2,x2,y2,&ix2,&iy2); - FrameBuffer_solidbox(p2->frame,ix1,iy1,ix2,iy2,color); -} - -/* ------------------------------------------------------------------------------- - Plot2D_interpbox(Plot2D *p2, double x1, double y1, double x2, double y2, - Pixel c1, Pixel c2, Pixel c3, Pixel c4) - - Plot a color-interpolated box on the 2D plot - ------------------------------------------------------------------------------- */ -void -Plot2D_interpbox(Plot2D *p2, double x1, double y1,double x2, double y2, - Pixel c1, Pixel c2, Pixel c3, Pixel c4) { - int ix1, ix2,iy1, iy2; - - Plot2D_transform(p2,x1,y1,&ix1,&iy1); - Plot2D_transform(p2,x2,y2,&ix2,&iy2); - FrameBuffer_interpbox(p2->frame,ix1,iy1,ix2,iy2,c1,c2,c3,c4); -} - -/* ------------------------------------------------------------------------------- - Plot2D_circle(Plot2D *p2, double x, double y, double radius, Pixel color) - - Make an outline circle on the 2D plot. - ------------------------------------------------------------------------------- */ -void -Plot2D_circle(Plot2D *p2, double x, double y, double radius, Pixel color) { - int ix, iy, ir; - - Plot2D_transform(p2,x,y,&ix,&iy); - ir = p2->dx * radius; /* This is really incorrect. Will need ellipse */ - if (ir > 1) - FrameBuffer_circle(p2->frame,ix,iy,ir,color); - else - FrameBuffer_plot(p2->frame,ix,iy,color); - -} - -/* ------------------------------------------------------------------------------- - Plot2D_solidcircle(Plot2D *p2, double x, double y, double radius, Pixel color) - - Make an solid circle on the 2D plot. - ------------------------------------------------------------------------------- */ -void -Plot2D_solidcircle(Plot2D *p2, double x, double y, double radius, Pixel color) { - int ix, iy, ir; - - Plot2D_transform(p2,x,y,&ix,&iy); - ir = p2->dx * radius; /* This is really incorrect. Will need ellipse */ - if (ir > 1) - FrameBuffer_solidcircle(p2->frame,ix,iy,ir,color); - else - FrameBuffer_plot(p2->frame,ix,iy,color); -} - -/* ------------------------------------------------------------------------------- - Plot2D_line(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color) - - Draw a line - ------------------------------------------------------------------------------- */ - -void -Plot2D_line(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color) { - int ix1, ix2, iy1, iy2; - - Plot2D_transform(p2,x1,y1,&ix1,&iy1); - Plot2D_transform(p2,x2,y2,&ix2,&iy2); - FrameBuffer_line(p2->frame,ix1,iy1,ix2,iy2,color); -} - - - -/* ------------------------------------------------------------------------------- - Plot2D_start(Plot2D *p2) - - This should be called before starting to make a 2D plot. It will change - the viewport coordinates for the framebuffer and do other stuff. - ------------------------------------------------------------------------------- */ - -void Plot2D_start(Plot2D *p2) { - if (p2) { - FrameBuffer_setclip(p2->frame, p2->view_xmin,p2->view_ymin,p2->view_xmax, p2->view_ymax); - p2->dx = (p2->view_xmax - p2->view_xmin)/(p2->xmax - p2->xmin); - p2->dy = (p2->view_ymax - p2->view_ymin)/(p2->ymax - p2->ymin); - } -} - -/* -------------------------------------------------------------------------- - void Plot2D_drawpixmap(Plot2D *p2, PixMap *pm, double x, double y, Pixel color, Pixel bgcolor) - - Draw a pixel map at the given coordinates. (Used for putting symbols on 2D - plots). - -------------------------------------------------------------------------- */ -void -Plot2D_drawpixmap(Plot2D *p2, PixMap *pm, double x, double y, Pixel color, Pixel bgcolor) { - int ix, iy; - - Plot2D_transform(p2,x,y,&ix,&iy); - FrameBuffer_drawpixmap(p2->frame,pm,ix,iy,color,bgcolor); -} - -/* ---------------------------------------------------------------------------- - void Plot2D_xaxis(Plot2D *p2, double x, double y, double xtick, int ticklength, Pixel color) - - Draw an X axis bar at location x,y with ticks spaced every xtick units. - Ticks are spaced starting at "x" - ----------------------------------------------------------------------------- */ - -void Plot2D_xaxis(Plot2D *p2, double x, double y, double xtick, int ticklength, Pixel color) { - int ix, iy,iy2; - double xt; - - /* Draw a line fox the axis */ - - Plot2D_line(p2,p2->xmin,y,p2->xmax,y,color); - xt = x; - while (xt >= p2->xmin) { - Plot2D_transform(p2,xt,y,&ix,&iy); - iy2 = iy+ticklength; - iy = iy-ticklength; - FrameBuffer_line(p2->frame,ix,iy,ix,iy2,color); - xt = xt - xtick; - } - xt = x + xtick; - while (xt < p2->xmax) { - Plot2D_transform(p2,xt,y,&ix,&iy); - iy2 = iy+ticklength; - iy = iy-ticklength; - FrameBuffer_line(p2->frame,ix,iy,ix,iy2,color); - xt = xt + xtick; - } -} - - -/* ---------------------------------------------------------------------------- - void Plot2D_yaxis(Plot2D *p2, double x, double y, double ytick, int ticklength, Pixel c) - - Draw an Y axis bar at location x,y with ticks spaced every xtick units. - Ticks are spaced starting at "y" - ----------------------------------------------------------------------------- */ - -void Plot2D_yaxis(Plot2D *p2, double x, double y, double ytick, int ticklength, Pixel color) { - int ix, iy, ix2; - double yt; - - /* Draw a line fox the axis */ - - Plot2D_line(p2,x,p2->ymin,x,p2->ymax,color); - yt = y; - while (yt >= p2->ymin) { - Plot2D_transform(p2,x,yt,&ix,&iy); - ix2 = ix+ticklength; - ix = ix-ticklength; - FrameBuffer_line(p2->frame,ix,iy,ix2,iy,color); - yt = yt - ytick; - } - yt = y + ytick; - while (yt < p2->ymax) { - Plot2D_transform(p2,x,yt,&ix,&iy); - ix2 = ix+ticklength; - ix = ix-ticklength; - FrameBuffer_line(p2->frame,ix,iy,ix2,iy,color); - yt = yt + ytick; - } -} - - -/* ------------------------------------------------------------------------- - Plot2D_triangle(Plot2D *p2, double x1, double y1, - double x2, double y2, - double x3, double y3, - Pixel fillcolor) - - This function draws a 2D outline triangle. - -------------------------------------------------------------------------- */ - -void Plot2D_triangle(Plot2D *p2, double x1, double y1, - double x2, double y2, - double x3, double y3, Pixel color) { - - Plot2D_line(p2,x1,y1,x2,y2,color); - Plot2D_line(p2,x2,y2,x3,y3,color); - Plot2D_line(p2,x3,y3,x1,y1,color); - -} - - -/* ------------------------------------------------------------------------- - Plot2D_solidtriangle(Plot2D *p2, double x1, double y1, - double x2, double y2, - double x3, double y3, - Pixel color) - - This function draws a 2D filled triangle. Can be used to - draw other primitives such as quadralaterals, etc... - - -------------------------------------------------------------------------- */ - -void Plot2D_solidtriangle(Plot2D *p2, double x1, double y1, - - double x2, double y2, - double x3, double y3, Pixel color) { - - int tx1, tx2, tx3, ty1, ty2, ty3; - - /* Transform the three points into screen coordinates */ - - Plot2D_transform(p2,x1,y1,&tx1,&ty1); - Plot2D_transform(p2,x2,y2,&tx2,&ty2); - Plot2D_transform(p2,x3,y3,&tx3,&ty3); - - FrameBuffer_solidtriangle(p2->frame,tx1,ty1,tx2,ty2,tx3,ty3,color); - -} - -/* ------------------------------------------------------------------------- - Plot2D_interptriangle(Plot2D *p2, double x1, double y1, Pixel c1, - double x2, double y2, Pixel c2, - double x3, double y3, Pixel c3); - - This function draws a 2D filled triangle with color interpolation. - Can be used to draw other primitives such as quadralaterals, etc... - -------------------------------------------------------------------------- */ - -void Plot2D_interptriangle(Plot2D *p2, double x1, double y1, Pixel c1, - double x2, double y2, Pixel c2, - double x3, double y3, Pixel c3) { - - int tx1, tx2, tx3, ty1, ty2, ty3; - - /* Transform the three points into screen coordinates */ - - Plot2D_transform(p2,x1,y1,&tx1,&ty1); - Plot2D_transform(p2,x2,y2,&tx2,&ty2); - Plot2D_transform(p2,x3,y3,&tx3,&ty3); - - FrameBuffer_interptriangle(p2->frame,tx1,ty1,c1,tx2,ty2,c2,tx3,ty3,c3); - -} - - - diff --git a/Examples/GIFPlot/Lib/plot3d.c b/Examples/GIFPlot/Lib/plot3d.c deleted file mode 100644 index 387e420e2..000000000 --- a/Examples/GIFPlot/Lib/plot3d.c +++ /dev/null @@ -1,2181 +0,0 @@ -/* ----------------------------------------------------------------------------- - * plot3d.c - * - * Three-dimensional plotting. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#define PLOT3D -#include "gifplot.h" -#include -#include - -#define ORTHO 1 -#define PERSPECTIVE 2 -/* ------------------------------------------------------------------------ - Plot3D *new_Plot3D(FrameBuffer *f, double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax) - - Creates a new 3D plot. Min and max coordinates are primarily used to - pick some default parameters. Returns NULL on failure - ------------------------------------------------------------------------- */ - -Plot3D *new_Plot3D(FrameBuffer *f, double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax) { - - Plot3D *p3; - void Plot3D_maketransform(Plot3D *p3); - - /* Check to make sure the framebuffer and min/max parameters are valid */ - - if (!f) return (Plot3D *) 0; - if ((xmin > xmax) || (ymin > ymax) || (zmin > zmax)) return (Plot3D *) 0; - - p3 = (Plot3D *) malloc(sizeof(Plot3D)); - p3->frame = f; - p3->xmin = xmin; - p3->ymin = ymin; - p3->zmin = zmin; - p3->xmax = xmax; - p3->ymax = ymax; - p3->zmax = zmax; - - /* Set view region to the entire size of the framebuffer */ - - p3->view_xmin = 0; - p3->view_ymin = 0; - p3->view_xmax = f->width; - p3->view_ymax = f->height; - p3->width = f->width; - p3->height = f->height; - - /* Calculate a center point based off the min and max coordinates given */ - - p3->xcenter = (xmax - xmin)/2.0 + xmin; - p3->ycenter = (ymax - ymin)/2.0 + ymin; - p3->zcenter = (zmax - zmin)/2.0 + zmin; - - /* Calculate the aspect ratio of the viewing region */ - - p3->aspect = (double) f->width/(double) f->height; - - /* Set default view parameters */ - p3->xshift = 1.0; - p3->yshift = 1.0; - p3->zoom = 0.5; - p3->fovy = 40.0; /* 40 degree field of view */ - - /* Create matrices */ - - p3->model_mat = new_Matrix(); - p3->view_mat = new_Matrix(); - p3->center_mat = new_Matrix(); - p3->fullmodel_mat = new_Matrix(); - p3->trans_mat = new_Matrix(); - p3->pers_mode = ORTHO; - - FrameBuffer_zresize(p3->frame,p3->width, p3->height); - Matrix_identity(p3->view_mat); - Matrix_identity(p3->model_mat); - Matrix_translate(p3->center_mat, -p3->xcenter,-p3->ycenter,-p3->zcenter); - Plot3D_maketransform(p3); - return p3; -} - -/* --------------------------------------------------------------------- - delete_Plot3D(Plot3D *p3) - - Deletes a 3D plot - --------------------------------------------------------------------- */ - -void delete_Plot3D(Plot3D *p3) { - if (p3) { - delete_Matrix(p3->view_mat); - delete_Matrix(p3->model_mat); - delete_Matrix(p3->trans_mat); - free((char *) p3); - } -} - -/* --------------------------------------------------------------------- - Plot3D *Plot3D_copy(Plot3D *p3) - - This makes a copy of the 3D plot structure and returns a pointer to it. - --------------------------------------------------------------------- */ - -Plot3D *Plot3D_copy(Plot3D *p3) { - Plot3D *c3; - if (p3) { - c3 = (Plot3D *) malloc(sizeof(Plot3D)); - if (c3) { - c3->frame = p3->frame; - c3->view_xmin = p3->view_xmin; - c3->view_ymin = p3->view_ymin; - c3->view_xmax = p3->view_xmax; - c3->view_ymax = p3->view_ymax; - c3->xmin = p3->xmin; - c3->ymin = p3->ymin; - c3->zmin = p3->zmin; - c3->xmax = p3->xmax; - c3->ymax = p3->ymax; - c3->zmax = p3->zmax; - c3->xcenter = p3->xcenter; - c3->ycenter = p3->ycenter; - c3->zcenter = p3->zcenter; - c3->fovy = p3->fovy; - c3->aspect = p3->aspect; - c3->znear = p3->znear; - c3->zfar = p3->zfar; - c3->center_mat = Matrix_copy(p3->center_mat); - c3->model_mat = Matrix_copy(p3->model_mat); - c3->view_mat = Matrix_copy(p3->view_mat); - c3->fullmodel_mat = Matrix_copy(p3->fullmodel_mat); - c3->trans_mat = Matrix_copy(p3->trans_mat); - c3->lookatz = p3->lookatz; - c3->xshift = p3->xshift; - c3->yshift = p3->yshift; - c3->zoom = p3->zoom; - c3->width = p3->width; - c3->height = p3->height; - c3->pers_mode = p3->pers_mode; - } - return c3; - } else { - return (Plot3D *) 0; - } -} - -/* ---------------------------------------------------------------------- - Plot3D_clear(Plot3D *p3, Pixel bgcolor) - - Clear the pixel and zbuffer only for the view region of this image. - ---------------------------------------------------------------------- */ -void -Plot3D_clear(Plot3D *p3, Pixel bgcolor) { - int i,j; - - for (i = p3->view_xmin; i < p3->view_xmax; i++) - for (j = p3->view_ymin; j < p3->view_ymax; j++) { - p3->frame->pixels[j][i] = bgcolor; - p3->frame->zbuffer[j][i] = ZMIN; - } -} - -/* --------------------------------------------------------------------- - Plot3D_maketransform(Plot3D *p3) - - This function builds the total 3D transformation matrix from a - collection of components. - - Trans = View * Rotation * Center - - Where View is the viewing transformation matrix, Rotation is the - model rotation matrix, Center is the translation matrix used to - center the Model at the origin. - --------------------------------------------------------------------- */ - -void -Plot3D_maketransform(Plot3D *p3) { - - Matrix_multiply(p3->model_mat,p3->center_mat, p3->fullmodel_mat); - Matrix_multiply(p3->view_mat,p3->fullmodel_mat, p3->trans_mat); -} - -/* --------------------------------------------------------------------- - Plot3D_perspective(Plot3D *p3, double fovy, double znear, double zfar) - - Sets up the perspective viewing transformation. Assumes "lookat" - has already been called. - --------------------------------------------------------------------- */ - -void -Plot3D_perspective(Plot3D *p3, double fovy, double znear, double zfar) { - double theta; - double mat[16]; - - p3->fovy = fovy; - p3->znear = znear; - p3->zfar = zfar; - - theta = 3.1415926*fovy/180.0; - - Matrix_identity(mat); - mat[0] = cos(theta/2.0)/(sin(theta/2.0)*p3->aspect); - mat[5] = cos(theta/2.0)/(sin(theta/2.0)); - mat[10] = -(zfar + znear)/(zfar-znear); - mat[14] = -1.0; - mat[11] = -(2*zfar*znear)/(zfar - znear); - mat[15] = 0.0; - - /* Update the view transformation matrix */ - - Matrix_multiply(mat,p3->view_mat,p3->view_mat); - - /* Update the global transformation matrix */ - - Plot3D_maketransform(p3); - p3->pers_mode = PERSPECTIVE; - -} - -/* --------------------------------------------------------------------- - Plot3D_lookat(Plot3D *p3, double z) - - A greatly simplified version of (lookat). Specifies the position - of the viewpoint. (can be used for moving image in or out). - - Destroys the current viewing transformation matrix, so it will have - to be recalculated. - --------------------------------------------------------------------- */ - -void -Plot3D_lookat(Plot3D *p3, double z) { - if (p3) { - Matrix_translate(p3->view_mat, 0,0,-z); - p3->lookatz = z; - Plot3D_maketransform(p3); - } -} - -/* ------------------------------------------------------------------------- - Plot3D_autoperspective(Plot3D *p3, double fovy) - - Automatically figures out a semi-decent viewpoint given the - min,max parameters currently set for this image - ------------------------------------------------------------------------- */ - -void -Plot3D_autoperspective(Plot3D *p3, double fovy) { - - /* Make a perspective transformation matrix for this system */ - - double zfar; - double znear; - double d, dmax; - double cx,cy,cz; - double xmin,xmax,ymin,ymax,zmin,zmax; - - xmin = p3->xmin; - ymin = p3->ymin; - zmin = p3->zmin; - xmax = p3->xmax; - ymax = p3->ymax; - zmax = p3->zmax; - cx = p3->xcenter; - cy = p3->ycenter; - cz = p3->zcenter; - - /* Calculate longest point from center point */ - - dmax = (xmin-cx)*(xmin-cx) + (ymin-cy)*(ymin-cy) + (zmin-cz)*(zmin-cz); - d = (xmax-cx)*(xmax-cx) + (ymin-cy)*(ymin-cy) + (zmin-cz)*(zmin-cz); - if (d > dmax) dmax = d; - d = (xmin-cx)*(xmin-cx) + (ymax-cy)*(ymax-cy) + (zmin-cz)*(zmin-cz); - if (d > dmax) dmax = d; - d = (xmax-cx)*(xmax-cx) + (ymax-cy)*(ymax-cy) + (zmin-cz)*(zmin-cz); - if (d > dmax) dmax = d; - d = (xmin-cx)*(xmin-cx) + (ymin-cy)*(ymin-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - d = (xmax-cx)*(xmax-cx) + (ymin-cy)*(ymin-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - d = (xmin-cx)*(xmin-cx) + (ymax-cy)*(ymax-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - d = (xmax-cx)*(xmax-cx) + (ymax-cy)*(ymax-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - - dmax = sqrt(dmax); - d = p3->lookatz; - - znear = d - dmax; - zfar = znear+1.5*dmax; - Plot3D_perspective(p3, fovy,znear,zfar); - -} - - -/* --------------------------------------------------------------------- - Plot3D_ortho(Plot3D *p3, double left, double right, double bottom, double top) - - Sets up an orthographic viewing transformation. - --------------------------------------------------------------------- */ - -void -Plot3D_ortho(Plot3D *p3, double left, double right, double bottom, double top) { - - - Matrix_identity(p3->view_mat); - p3->view_mat[0] = (2.0/(right - left))/p3->aspect; - p3->view_mat[5] = 2.0/(top - bottom); - p3->view_mat[10] = -1; - p3->view_mat[15] = 1.0; - p3->view_mat[3] = -(right+left)/(right-left); - p3->view_mat[7] = -(top+bottom)/(top-bottom); - - /* Update the global transformation matrix */ - - Plot3D_maketransform(p3); - p3->pers_mode = ORTHO; - p3->ortho_left = left; - p3->ortho_right = right; - p3->ortho_bottom = bottom; - p3->ortho_top = top; - -} - -/* --------------------------------------------------------------------- - Plot3D_autoortho(Plot3D *p3) - - Automatically pick an orthographic projection that's probably - pretty good. - --------------------------------------------------------------------- */ - -void -Plot3D_autoortho(Plot3D *p3) { - - /* Make a perspective transformation matrix for this system */ - - double d, dmax; - double cx,cy,cz; - double xmin,xmax,ymin,ymax,zmin,zmax; - - xmin = p3->xmin; - ymin = p3->ymin; - zmin = p3->zmin; - xmax = p3->xmax; - ymax = p3->ymax; - zmax = p3->zmax; - cx = p3->xcenter; - cy = p3->ycenter; - cz = p3->zcenter; - - /* Calculate longest point from center point */ - - dmax = (xmin-cx)*(xmin-cx) + (ymin-cy)*(ymin-cy) + (zmin-cz)*(zmin-cz); - d = (xmax-cx)*(xmax-cx) + (ymin-cy)*(ymin-cy) + (zmin-cz)*(zmin-cz); - if (d > dmax) dmax = d; - d = (xmin-cx)*(xmin-cx) + (ymax-cy)*(ymax-cy) + (zmin-cz)*(zmin-cz); - if (d > dmax) dmax = d; - d = (xmax-cx)*(xmax-cx) + (ymax-cy)*(ymax-cy) + (zmin-cz)*(zmin-cz); - if (d > dmax) dmax = d; - d = (xmin-cx)*(xmin-cx) + (ymin-cy)*(ymin-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - d = (xmax-cx)*(xmax-cx) + (ymin-cy)*(ymin-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - d = (xmin-cx)*(xmin-cx) + (ymax-cy)*(ymax-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - d = (xmax-cx)*(xmax-cx) + (ymax-cy)*(ymax-cy) + (zmax-cz)*(zmax-cz); - if (d > dmax) dmax = d; - - dmax = sqrt(dmax); - - Plot3D_ortho(p3,-dmax,dmax,-dmax,dmax); - -} - - - -/* ------------------------------------------------------------------------- - Plot3D_setview(Plot3D *p3, int vxmin, int vymin, int vxmax, int vymax) - - Sets the viewport for this 3D graph. Will recalculate all of the - local viewing transformation matrices accordingly. - ------------------------------------------------------------------------- */ -void -Plot3D_setview(Plot3D *p3, int vxmin, int vymin, int vxmax, int vymax) { - if (p3) { - if ((vxmin > vxmax) || (vymin >vymax)) return; - p3->view_xmin = vxmin; - p3->view_ymin = vymin; - p3->view_xmax = vxmax; - p3->view_ymax = vymax; - p3->width = (vxmax - vxmin); - p3->height = (vymax - vymin); - p3->aspect = (double) p3->width/(double) p3->height; - - /* Fix up the viewing transformation matrix */ - - if (p3->pers_mode == PERSPECTIVE) { - Plot3D_lookat(p3,p3->lookatz); - Plot3D_perspective(p3,p3->fovy,p3->znear,p3->zfar); - } else { - Plot3D_ortho(p3,p3->ortho_left,p3->ortho_right,p3->ortho_bottom, p3->ortho_top); - } - FrameBuffer_setclip(p3->frame,vxmin,vymin,vxmax,vymax); - } -} - -/* --------------------------------------------------------------------------- - Plot2D_start(Plot2D *p3) - - Set up viewing region and other parameters for this image. - --------------------------------------------------------------------------- */ - -void -Plot3D_start(Plot3D *p3) { - if (p3) - FrameBuffer_setclip(p3->frame, p3->view_xmin,p3->view_ymin,p3->view_xmax, p3->view_ymax); - -} - -/* ------------------------------------------------------------------------- - Plot3D_plot(Plot3D *p3, double x, double y, double z, Pixel Color) - - Plot a 3D point - ------------------------------------------------------------------------- */ - -void -Plot3D_plot(Plot3D *p3, double x, double y, double z, Pixel color) { - - GL_Vector t; - int ix, iy; - double invw; - FrameBuffer *f; - - /* Perform a transformation */ - - Matrix_transform4(p3->trans_mat,x,y,z,1,&t); - - /* Scale the coordinates into unit cube */ - - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; -#ifdef GL_DEBUG - fprintf(stdout,"t.x = %g, t.y = %g, t.z = %g\n", t.x,t.y,t.z); -#endif - /* Calculate the x and y coordinates */ - - ix = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5); - iy = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5); - - if ((ix >= 0) && (ix < p3->width) && - (iy >= 0) && (ix < p3->height)) { - ix += p3->view_xmin; - iy += p3->view_ymin; - f = p3->frame; - if (t.z <= f->zbuffer[iy][ix]) { - f->pixels[iy][ix] = color; - f->zbuffer[iy][ix] = t.z; - } - } -} - -/* ---------------------------------------------------------------------- - Plot3D_rotx(Plot3D *p3, double deg) - - Rotate the model around its x axis. - ---------------------------------------------------------------------- */ - -void -Plot3D_rotx(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatex(temp,deg); /* Construct a x rotation matrix */ - Matrix_multiply(p3->model_mat,temp,p3->model_mat); - Plot3D_maketransform(p3); - -} - -/* ---------------------------------------------------------------------- - Plot3D_roty(Plot3D *p3, double deg) - - Rotate the model around its y axis. - ---------------------------------------------------------------------- */ - -void -Plot3D_roty(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatey(temp,deg); /* Construct a y rotation matrix */ - Matrix_multiply(p3->model_mat,temp,p3->model_mat); - Plot3D_maketransform(p3); - -} - -/* ---------------------------------------------------------------------- - Plot3D_rotz(Plot3D *p3, double deg) - - Rotate the model around its z axis. - ---------------------------------------------------------------------- */ - -void -Plot3D_rotz(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatez(temp,deg); /* Construct a z rotation matrix */ - Matrix_multiply(p3->model_mat,temp,p3->model_mat); - Plot3D_maketransform(p3); - -} - - -/* ---------------------------------------------------------------------- - Plot3D_rotd(Plot3D *p3, double deg) - - Rotate the model down - ---------------------------------------------------------------------- */ - -void -Plot3D_rotd(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatex(temp,deg); /* Construct a x rotation matrix */ - Matrix_multiply(temp, p3->model_mat,p3->model_mat); - Plot3D_maketransform(p3); - -} - - -/* ---------------------------------------------------------------------- - Plot3D_rotu(Plot3D *p3, double deg) - - Rotate the model up - ---------------------------------------------------------------------- */ - -void -Plot3D_rotu(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatex(temp,-deg); /* Construct a x rotation matrix */ - Matrix_multiply(temp,p3->model_mat,p3->model_mat); - Plot3D_maketransform(p3); - -} - - -/* ---------------------------------------------------------------------- - Plot3D_rotr(Plot3D *p3, double deg) - - Rotate the model down - ---------------------------------------------------------------------- */ - -void -Plot3D_rotr(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatey(temp,deg); /* Construct a y rotation matrix */ - Matrix_multiply(temp, p3->model_mat,p3->model_mat); - Plot3D_maketransform(p3); - -} - - -/* ---------------------------------------------------------------------- - Plot3D_rotl(Plot3D *p3, double deg) - - Rotate the model left - ---------------------------------------------------------------------- */ - -void -Plot3D_rotl(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatey(temp,-deg); /* Construct a y rotation matrix */ - Matrix_multiply(temp,p3->model_mat,p3->model_mat); - Plot3D_maketransform(p3); - -} - - -/* ---------------------------------------------------------------------- - Plot3D_rotc(Plot3D *p3, double deg) - - Rotate the model around center point - ---------------------------------------------------------------------- */ - -void -Plot3D_rotc(Plot3D *p3, double deg) { - double temp[16]; - - Matrix_rotatez(temp,-deg); /* Construct a z rotation matrix */ - Matrix_multiply(temp,p3->model_mat,p3->model_mat); - Plot3D_maketransform(p3); -} - -/* ------------------------------------------------------------------------- - Plot3D_zoom(Plot3D *p3, double percent) - - Zooms in or out the current image. percent defines a percentage of - zoom. - - Zooming is actually done by adjusting the perspective field of view - instead of scaling the model or moving in the viewpoint. This - seems to work the best. - ------------------------------------------------------------------------- */ - -void -Plot3D_zoom(Plot3D *p3, double percent) { - - double scale; - double dx; - if (percent <= 0) return; - scale = percent/100.0; - - dx = (1.0/scale - 1.0)/(2*p3->zoom); /* Don't even ask where this came from */ - p3->xshift += dx; - p3->yshift += dx; - p3->zoom = p3->zoom*scale; - -#ifdef OLD - p3->fovy = p3->fovy*scale; - if (p3->fovy > 170.0) p3->fovy = 170.0; - if (p3->fovy == 0) p3->fovy = 0.0001; - Plot3D_lookat(p3,p3->lookatz); - Plot3D_perspective(p3,p3->fovy,p3->znear,p3->zfar); -#endif -} - -/* -------------------------------------------------------------------------- - Plot3D_left(Plot3D *p3, double s) - - Shifts the image to the left by s units. This is a little funky. - - s is scaled so that s = 100 equals one full screen. - -------------------------------------------------------------------------- */ -void -Plot3D_left(Plot3D *p3, double s) { - p3->xshift -= (s/100.0)/p3->zoom; -} - -/* -------------------------------------------------------------------------- - Plot3D_right(Plot3D *p3, double s) - - Shifts the image to the right by s units. - - s is scaled so that s = 100 equals one full screen. - -------------------------------------------------------------------------- */ -void -Plot3D_right(Plot3D *p3, double s) { - p3->xshift += (s/100.0)/p3->zoom; -} - -/* -------------------------------------------------------------------------- - Plot3D_up(Plot3D *p3, double s) - - Shifts the image up left by s units. - - s is scaled so that s = 100 equals one full screen. - -------------------------------------------------------------------------- */ -void -Plot3D_up(Plot3D *p3, double s) { - p3->yshift += (s/100.0)/p3->zoom; -} - -/* -------------------------------------------------------------------------- - Plot3D_down(Plot3D *p3, double s) - - Shifts the image down by s units. - - s is scaled so that s = 100 equals one full screen. - -------------------------------------------------------------------------- */ -void -Plot3D_down(Plot3D *p3, double s) { - p3->yshift -= (s/100.0)/p3->zoom; -} - -/* ------------------------------------------------------------------------- - Plot3D_center(Plot3D *p3, double cx, double cy) - - Centers the image on a point in the range (0,0) - (100,100) - ------------------------------------------------------------------------- */ -void -Plot3D_center(Plot3D *p3, double cx, double cy) { - Plot3D_left(p3,cx-50); - Plot3D_down(p3,cy-50); -} - - - -/*************************************************************************** - * 3d Primitives * - ***************************************************************************/ - -/* ------------------------------------------------------------------------- - Plot3D_horizontal(Plot3D *p3, int xmin, int xmax, int y, double z1, double z2, Pixel color) - - Draws a "Horizontal" line on the framebuffer between two screen coordinates, - but also supplies z-values and zbuffering. This function probably isn't - too useful by itself, but will be used by a number of other primitives. - -------------------------------------------------------------------------- */ - -void Plot3D_horizontal(Plot3D *p3, int xmin, int xmax, int y, Zvalue z1, Zvalue z2, Pixel color) { - Pixel *p; - FrameBuffer *f; - int i; - Zvalue *zbuf,z,mz; - int startx, endx; - - f = p3->frame; - if ((y < f->ymin) || (y >= f->ymax)) return; - if (xmin > f->xmax) return; - if (xmin < f->xmin) startx = f->xmin; - else startx = xmin; - if (xmax < f->xmin) return; - if (xmax >= f->xmax) endx = f->xmax - 1; - else endx = xmax; - - /* Calculate z slope */ - - if (xmax != xmin) { - mz = (Zvalue) ((double) (z2 - z1)/(double) (xmax - xmin)); - } else { - mz = 0; - } - - /* Draw it */ - - p = &f->pixels[y][startx]; - zbuf = &f->zbuffer[y][startx]; - z = (Zvalue) (mz*(startx-xmin) + z1); - for (i = startx; i <= endx; i++, p++, zbuf++,z+=mz) { - if (z <= *zbuf) { - *p = color; - *zbuf = z; - } - } -} - - -/* ------------------------------------------------------------------------- - Plot3D_vertical(Plot3D *p3, int ymin, int ymax, int x, double z1, double z2, Pixel color) - - Draws a "Vertical" line on the framebuffer between two screen coordinates, - but also supplies z-values and zbuffering. This function probably isn't - too useful by itself, but will be used by a number of other primitives. - -------------------------------------------------------------------------- */ - -void Plot3D_vertical(Plot3D *p3, int ymin, int ymax, int x, Zvalue z1, Zvalue z2, Pixel color) { - Pixel *p; - FrameBuffer *f; - int i; - Zvalue *zbuf,z,mz; - int starty, endy; - - f = p3->frame; - if ((x < f->xmin) || (x >= f->xmax)) return; - if (ymin >= f->ymax) return; - if (ymin < f->ymin) starty = f->ymin; - else starty = ymin; - if (ymax < f->ymin) return; - if (ymax >= f->ymax) endy = f->ymax - 1; - else endy = ymax; - - /* Calculate z slope */ - - mz = (double) (z2 - z1)/(double) (ymax - ymin); - - /* Draw it */ - - p = &f->pixels[starty][x]; - zbuf = &f->zbuffer[starty][x]; - for (i = starty; i <= endy; i++, p+=f->width, zbuf+=f->width) { - z = (Zvalue) (mz*(i-ymin) + z1); - if (z <= *zbuf) { - *p = color; - *zbuf = z; - } - } -} - -/* ------------------------------------------------------------------------------- - Plot3D_linetransform(Plot3D *p3, int x1, int y1, Zvalue z1, - int x2, int y2, Zvalue z2, Pixel c) - - Draw a 3D line between points that have already been transformed into - 3D space. - - Uses a Bresenham line algorithm, but with linear interpolation between - Zvalues. - ------------------------------------------------------------------------------- */ - -void -Plot3D_linetransform(Plot3D *p3, int x1, int y1, Zvalue z1, int x2, int y2, Zvalue z2, Pixel c) { - - int orig_x1, orig_y1, orig_x2,orig_y2; - Zvalue zt; - - /* Bresenham line drawing parameters */ - FrameBuffer *f; - int dx,dy,dxneg,dyneg, inc1,inc2,di; - int x, y, xpixels, ypixels, xt, yt; - Pixel *p; - double m; - int end1 = 0, end2 = 0; - Zvalue *zbuf,mz,z; - - f = p3->frame; - - /* Need to figure out where in the heck this line is */ - - dx = x2 - x1; - dy = y2 - y1; - - if ((dx == 0) && (dy == 0)) { - if ((x1 < f->xmin) || (x1 >= f->xmax) || - (y1 < f->ymin) || (y1 >= f->ymax)) return; - if (z1 <= f->zbuffer[y1][x1]) { - f->pixels[y1][x1] = c; - } - return; - } - if (dx == 0) { - /* Draw a Vertical Line */ - if (y1 < y2) - Plot3D_vertical(p3,y1,y2,x1,z1,z2,c); - else - Plot3D_vertical(p3,y2,y1,x1,z2,z1,c); - return; - } - if (dy == 0) { - /* Draw a Horizontal Line */ - if (x1 < x2) - Plot3D_horizontal(p3,x1,x2,y1,z1,z2,c); - else - Plot3D_horizontal(p3,x2,x1,y1,z2,z1,c); - return; - } - - /* Figure out where in the heck these lines are using the - Cohen-Sutherland Line Clipping Scheme. */ - - end1 = ((x1 - f->xmin) < 0) | - (((f->xmax- 1 - x1) < 0) << 1) | - (((y1 - f->ymin) < 0) << 2) | - (((f->ymax-1 - y1) < 0) << 3); - - end2 = ((x2 - f->xmin) < 0) | - (((f->xmax-1 - x2) < 0) << 1) | - (((y2 - f->ymin) < 0) << 2) | - (((f->ymax-1 - y2) < 0) << 3); - - if (end1 & end2) return; /* Nope : Not visible */ - - /* Make sure points have a favorable orientation */ - - if (x1 > x2) { - xt = x1; - x1 = x2; - x2 = xt; - yt = y1; - y1 = y2; - y2 = yt; - zt = z1; - z1 = z2; - z2 = zt; - } - - /* Save original points before we clip them off */ - orig_x1 = x1; - orig_y1 = y1; - orig_x2 = x2; - orig_y2 = y2; - - /* Clip against the boundaries */ - m = (y2 - y1)/(double) (x2-x1); - if (x1 < f->xmin) { - y1 = (f->xmin - x1)*m + y1; - x1 = f->xmin; - } - if (x2 >= f->xmax) { - y2 = (f->xmax -1 -x1)*m + y1; - x2 = f->xmax - 1; - } - - if (y1 > y2) { - xt = x1; - x1 = x2; - x2 = xt; - yt = y1; - y1 = y2; - y2 = yt; - zt = z1; - z1 = z2; - z2 = zt; - - /* Swap original points */ - - xt = orig_x1; - orig_x1 = orig_x2; - orig_x2 = xt; - yt = orig_y1; - orig_y1 = orig_y2; - orig_y2 = yt; - } - - m = 1/m; - if (y1 < f->ymin) { - x1 = (f->ymin - y1)*m + x1; - y1 = f->ymin; - } - if (y2 >= f->ymax) { - x2 = (f->ymax-1-y1)*m + x1; - y2 = f->ymax-1; - } - - if ((x1 < f->xmin) || (x1 >= f->xmax) || (y1 < f->ymin) || (y1 >= f->ymax) || - (x2 < f->xmin) || (x2 >= f->xmax) || (y2 < f->ymin) || (y2 >= f->ymax)) return; - - dx = x2 - x1; - dy = y2 - y1; - xpixels = f->width; - ypixels = f->height; - - dxneg = (dx < 0) ? 1 : 0; - dyneg = (dy < 0) ? 1 : 0; - - dx = abs(dx); - dy = abs(dy); - if (dx >= dy) { - /* Slope between -1 and 1. */ - mz = (z2 - z1)/(orig_x2 - orig_x1); /* Z interpolation slope */ - if (dxneg) { - x = x1; - y = y1; - x1 = x2; - y1 = y2; - x2 = x; - y2 = y; - dyneg = !dyneg; - } - inc1 = 2*dy; - inc2 = 2*(dy-dx); - di = 2*dy-dx; - - /* Draw a line using x as independent variable */ - - p = &f->pixels[y1][x1]; - zbuf = &f->zbuffer[y1][x1]; - x = x1; - while (x <= x2) { - /* Do a z-buffer check */ - z = mz*(x-orig_x1)+z1; - if (z <= *zbuf){ - *p = c; - *zbuf = z; - } - p++; - zbuf++; - if (di < 0) { - di = di + inc1; - } else { - if (dyneg) { - p = p - xpixels; - zbuf = zbuf - xpixels; - di = di + inc2; - } else { - p = p + xpixels; - zbuf = zbuf + xpixels; - di = di + inc2; - } - } - x++; - } - } else { - /* Slope < -1 or > 1 */ - mz = (z2 - z1)/(double) (orig_y2 - orig_y1); - if (dyneg) { - x = x1; - y = y1; - x1 = x2; - y1 = y2; - x2 = x; - y2 = y; - dxneg = !dxneg; - } - inc1 = 2*dx; - inc2 = 2*(dx-dy); - di = 2*dx-dy; - - /* Draw a line using y as independent variable */ - - p = &f->pixels[y1][x1]; - zbuf = &f->zbuffer[y1][x1]; - y = y1; - while (y <= y2) { - /* Do a z-buffer check */ - z = mz*(y-orig_y1)+z1; - if (z <= *zbuf) { - *p = c; - *zbuf = z; - } - p = p + xpixels; - zbuf = zbuf + xpixels; - if (di < 0) { - di = di + inc1; - } else { - if (dxneg) { - p = p - 1; - zbuf = zbuf - 1; - di = di + inc2; - } else { - p = p + 1; - zbuf = zbuf + 1; - di = di + inc2; - } - } - y++; - } - } -} - -/* --------------------------------------------------------------------------- - Plot3D_line(Plot3D *p3, double x1, double y1, double z1, double x2, double y2, double z2,int color) - - Draws a line in 3D space. This is done as follows (for lack of a better - method). - - 1. The points (x1,y1,z1) and (x2,y2,z2) are transformed into screen coordinates - 2. We draw the line using a modified Bresenham line algorithm. - 3. Zbuffer values are linearly interpolated between the two points. - ---------------------------------------------------------------------------- */ - -void -Plot3D_line(Plot3D *p3, double fx1, double fy1, double fz1, double fx2, double fy2, - double fz2, Pixel c) { - - /* 3D Transformation parameters */ - GL_Vector t; - double invw; - int x1,y1,x2,y2; - Zvalue z1,z2; - - /* Transform the two points into screen coordinates */ - - Matrix_transform4(p3->trans_mat,fx1,fy1,fz1,1,&t); /* Point 1 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - x1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - y1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - z1 = t.z; - - Matrix_transform4(p3->trans_mat,fx2,fy2,fz2,1,&t); /* Point 2 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - x2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - y2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - z2 = t.z; - Plot3D_linetransform(p3,x1,y1,z1,x2,y2,z2,c); -} - - -/* ------------------------------------------------------------------------- - Plot3D_triangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - Pixel fillcolor) - - This function draws a 3D z-buffered outline triangle. - -------------------------------------------------------------------------- */ - -void Plot3D_triangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color) { - - int tx1, tx2, tx3, ty1, ty2, ty3; - Zvalue tz1, tz2, tz3; - GL_Vector t; - double invw; - - /* Transform the three points into screen coordinates */ - - Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz1 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz2 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz3 = (Zvalue) t.z; - - - Plot3D_linetransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,color); - Plot3D_linetransform(p3,tx1,ty1,tz1,tx3,ty3,tz3,color); - Plot3D_linetransform(p3,tx2,ty2,tz2,tx3,ty3,tz3,color); -} - - -/* ------------------------------------------------------------------------- - Plot3D_solidtriangletransform(Plot3D *p3, int tx1, int ty2, Zvalue tz1, - int tx2, int ty2, Zvalue tz2, - int tx3, int ty3, Zvalue tz3, Pixel color) - - This function draws a 3D z-buffered filled triangle. Assumes three - points have already been transformed into screen coordinates. - - General idea : - 1. Transform the three points into screen coordinates - 2. Order three points vertically on screen. - 3. Check for degenerate cases (where 3 points are colinear). - 4. Fill in the resulting triangle using horizontal lines. - -------------------------------------------------------------------------- */ - -void Plot3D_solidtriangletransform(Plot3D *p3, int tx1, int ty1, Zvalue tz1, - int tx2, int ty2, Zvalue tz2, - int tx3, int ty3, Zvalue tz3, Pixel color) { - int tempx, tempy; - Zvalue tempz; - double m1,m2,m3, mz1, mz2, mz3; - int y; - int ix1, ix2; - Zvalue zz1, zz2; - FrameBuffer *f; - register double fy1,fy2; - register Zvalue fz1,fz2; - - f = p3->frame; - - /* Check for degenerate cases here */ - - if ((ty1 == ty2) && (ty2 == ty3)) { - if (tx2 < tx1) { /* Swap points 1 and 2 if 2 is higher */ - tempx = tx1; - tempz = tz1; - tx1 = tx2; - tz1 = tz2; - tx2 = tempx; - tz2 = tempz; - } - if (tx3 < tx1) { /* Swap points 1 and 3 if 3 is higher */ - tempx = tx1; - tempz = tz1; - tx1 = tx3; - tz1 = tz3; - tx3 = tempx; - tz3 = tempz; - } - if (tx3 < tx2) { /* Swap points 2 and 3 if 3 is higher */ - tempx = tx2; - tempz = tz2; - tx2 = tx3; - tz2 = tz3; - tx3 = tempx; - tz3 = tempz; - } - - /* Points are aligned horizontally. Handle as a special case */ - /* Just draw three lines using the outline color */ - - Plot3D_horizontal(p3,tx1,tx2,ty1,tz1,tz3,color); - - /* Plot3D_linetransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,color); - Plot3D_linetransform(p3,tx1,ty1,tz1,tx3,ty3,tz3,color); - Plot3D_linetransform(p3,tx2,ty2,tz2,tx3,ty3,tz3,color); - */ - - return; - } - - /* Figure out which point has the greatest "y" value */ - - if (ty2 > ty1) { /* Swap points 1 and 2 if 2 is higher */ - tempx = tx1; - tempy = ty1; - tempz = tz1; - tx1 = tx2; - ty1 = ty2; - tz1 = tz2; - tx2 = tempx; - ty2 = tempy; - tz2 = tempz; - } - if (ty3 > ty1) { /* Swap points 1 and 3 if 3 is higher */ - tempx = tx1; - tempy = ty1; - tempz = tz1; - tx1 = tx3; - ty1 = ty3; - tz1 = tz3; - tx3 = tempx; - ty3 = tempy; - tz3 = tempz; - } - if (ty3 > ty2) { /* Swap points 2 and 3 if 3 is higher */ - tempx = tx2; - tempy = ty2; - tempz = tz2; - tx2 = tx3; - ty2 = ty3; - tz2 = tz3; - tx3 = tempx; - ty3 = tempy; - tz3 = tempz; - } - - /* Points are now order so that t_1 is the highest point, t_2 is the - middle point, and t_3 is the lowest point */ - - if (ty2 < ty1) { - /* First process line segments between (x1,y1)-(x2,y2) - And between (x1,y1),(x3,y3) */ - - m1 = (double) (tx2 - tx1)/(double) (ty2 - ty1); - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - mz1 = (tz2 - tz1)/(double) (ty2 - ty1); - mz2 = (tz3 - tz1)/(double) (ty3 - ty1); - - y = ty1; - fy1 = m1*(y-ty1)+0.5 + tx1; - fy2 = m2*(y-ty1)+0.5 + tx1; - fz1 = mz1*(y-ty1) + tz1; - fz2 = mz2*(y-ty1) + tz1; - while (y >= ty2) { - /* Replace with bresenham scheme */ - /* Calculate x values from slope */ - ix1 = (int) fy1; - ix2 = (int) fy2; - zz1 = fz1; - zz2 = fz2; - fy1-= m1; - fy2-= m2; - fz1-= mz1; - fz2-= mz2; - if (ix1 > ix2) - Plot3D_horizontal(p3,ix2,ix1,y,zz2,zz1,color); - else - Plot3D_horizontal(p3,ix1,ix2,y,zz1,zz2,color); - y--; - } - } - if (ty3 < ty2) { - /* Draw lower half of the triangle */ - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - m3 = (double) (tx3 - tx2)/(double)(ty3 - ty2); - mz2 = (tz3 - tz1)/(double) (ty3 - ty1); - mz3 = (tz3 - tz2)/(double) (ty3 - ty2); - y = ty2; - while (y >= ty3) { - ix1 = (int) (m3*(y-ty2)+0.5)+tx2; - ix2 = (int) (m2*(y-ty1)+0.5)+tx1; - zz1 = mz3*(y-ty2)+tz2; - zz2 = mz2*(y-ty1)+tz1; - if (ix1 > ix2) - Plot3D_horizontal(p3,ix2,ix1,y,zz2,zz1,color); - else - Plot3D_horizontal(p3,ix1,ix2,y,zz1,zz2,color); - y--; - } - } -} - -/* ------------------------------------------------------------------------- - Plot3D_solidtriangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - Pixel color) - - This function draws a 3D z-buffered filled triangle. Can be used to - draw other primitives such as quadralaterals, etc... - - This function simply transforms the given points and calls - Plot3D_SolidTriangleTransform(). - -------------------------------------------------------------------------- */ - -void Plot3D_solidtriangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color) { - - int tx1, tx2, tx3, ty1, ty2, ty3; - Zvalue tz1, tz2, tz3; - GL_Vector t; - double invw; - Matrix a; - register double xshift, yshift, zoom, width, height, view_xmin, view_ymin; - - a = p3->trans_mat; - xshift = p3->xshift; - yshift = p3->yshift; - zoom = p3->zoom; - height = p3->height; - width = p3->width; - view_xmin = p3->view_xmin; - view_ymin = p3->view_ymin; - - /* Transform the three points into screen coordinates */ - - t.w = a[12]*x1 + a[13]*y1 + a[14]*z1 + a[15]; - invw = 1.0/t.w; - t.x = (a[0]*x1 + a[1]*y1 + a[2]*z1 + a[3])*invw; - t.y = (a[4]*x1 + a[5]*y1 + a[6]*z1 + a[7])*invw; - t.z = (a[8]*x1 + a[9]*y1 + a[10]*z1 + a[11])*invw; - - tx1 = (int) ((t.x +xshift)*zoom*width + 0.5) + view_xmin; - ty1 = (int) ((t.y +yshift)*zoom*height + 0.5) + view_ymin; - tz1 = (Zvalue) t.z; - - - t.w = a[12]*x2 + a[13]*y2 + a[14]*z2 + a[15]; - invw = 1.0/t.w; - t.x = (a[0]*x2 + a[1]*y2 + a[2]*z2 + a[3])*invw; - t.y = (a[4]*x2 + a[5]*y2 + a[6]*z2 + a[7])*invw; - t.z = (a[8]*x2 + a[9]*y2 + a[10]*z2 + a[11])*invw; - tx2 = (int) ((t.x +xshift)*zoom*width + 0.5) + view_xmin; - ty2 = (int) ((t.y +yshift)*zoom*height + 0.5) + view_ymin; - tz2 = (Zvalue) t.z; - - t.w = a[12]*x3 + a[13]*y3 + a[14]*z3 + a[15]; - invw = 1.0/t.w; - t.x = (a[0]*x3 + a[1]*y3 + a[2]*z3 + a[3])*invw; - t.y = (a[4]*x3 + a[5]*y3 + a[6]*z3 + a[7])*invw; - t.z = (a[8]*x3 + a[9]*y3 + a[10]*z3 + a[11])*invw; - tx3 = (int) ((t.x +xshift)*zoom*width + 0.5) + view_xmin; - ty3 = (int) ((t.y +yshift)*zoom*height + 0.5) + view_ymin; - tz3 = (Zvalue) t.z; - - Plot3D_solidtriangletransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,tx3,ty3,tz3,color); - -} - - -/* ------------------------------------------------------------------------- - Plot3D_horizontalinterp(Plot3D *p3, int xmin, int xmax, int y, - double z1, double z2, Pixel c1, Pixel c2) - - Draws a "Horizontal" line on the framebuffer between two screen coordinates, - but also supplies z-values and zbuffering. Performs a color interpolation - between c1 and c2. This is primarily used by the SolidTriangleInterp() - function to give the illusion of smooth surfaces. - -------------------------------------------------------------------------- */ - -void Plot3D_horizontalinterp(Plot3D *p3, int xmin, int xmax, int y, - Zvalue z1, Zvalue z2, Pixel c1, Pixel c2) { - Pixel *p; - FrameBuffer *f; - int i; - Zvalue *zbuf,z,mz; - double mc; - int startx, endx; - double invdx; - - f = p3->frame; - if ((y < f->ymin) || (y >= f->ymax)) return; - if (xmin >= f->xmax) return; - if (xmin < f->xmin) startx = f->xmin; - else startx = xmin; - if (xmax < f->xmin) return; - if (xmax >= f->xmax) endx = f->xmax - 1; - else endx = xmax; - - /* Calculate z slope */ - if (xmax != xmin) { - invdx = 1.0/(double) (xmax-xmin); - } else { - invdx = 0; - } - - mz = (Zvalue) (z2 - z1)*invdx; - - /* Calculate c slope */ - - mc = (double) (c2 - c1)*invdx; - - /* Draw it */ - - p = &f->pixels[y][startx]; - zbuf = &f->zbuffer[y][startx]; - for (i = startx; i <= endx; i++, p++, zbuf++) { - z = (Zvalue) (mz*(i-xmin) + z1); - if (z <= *zbuf) { - *p = (Pixel) (mc*(i-xmin)+c1); - *zbuf = z; - } - } -} - -/* ------------------------------------------------------------------------- - Plot3D_interptriangletransform(Plot3D *p3, - int tx1, int ty2, Zvalue tz1, Pixel c1, - int tx2, int ty2, Zvalue tz2, Pixel c2, - int tx3, int ty3, Zvalue tz3, Pixel c3) - - This function draws a 3D z-buffered filled triangle with color - interpolation. Assumes three points have already been transformed - into screen coordinates. - - General idea : - 1. Transform the three points into screen coordinates - 2. Order three points vertically on screen. - 3. Check for degenerate cases (where 3 points are colinear). - 4. Fill in the resulting triangle using horizontal lines. - 5. Colors are interpolated between end points - -------------------------------------------------------------------------- */ - -void Plot3D_interptriangletransform(Plot3D *p3, - int tx1, int ty1, Zvalue tz1, Pixel c1, - int tx2, int ty2, Zvalue tz2, Pixel c2, - int tx3, int ty3, Zvalue tz3, Pixel c3) { - int tempx, tempy; - Zvalue tempz; - double m1,m2,m3, mz1, mz2, mz3; - double mc1,mc2,mc3; - Pixel ic1,ic2,tempc; - int y; - int ix1, ix2; - Zvalue zz1, zz2; - FrameBuffer *f; - - f = p3->frame; - - /* Figure out which point has the greatest "y" value */ - - if (ty2 > ty1) { /* Swap points 1 and 2 if 2 is higher */ - tempx = tx1; - tempy = ty1; - tempz = tz1; - tempc = c1; - tx1 = tx2; - ty1 = ty2; - tz1 = tz2; - c1 = c2; - tx2 = tempx; - ty2 = tempy; - tz2 = tempz; - c2 = tempc; - } - if (ty3 > ty1) { /* Swap points 1 and 3 if 3 is higher */ - tempx = tx1; - tempy = ty1; - tempz = tz1; - tempc = c1; - tx1 = tx3; - ty1 = ty3; - tz1 = tz3; - c1 = c3; - tx3 = tempx; - ty3 = tempy; - tz3 = tempz; - c3 = tempc; - } - if (ty3 > ty2) { /* Swap points 2 and 3 if 3 is higher */ - tempx = tx2; - tempy = ty2; - tempz = tz2; - tempc = c2; - tx2 = tx3; - ty2 = ty3; - tz2 = tz3; - c2 = c3; - tx3 = tempx; - ty3 = tempy; - tz3 = tempz; - c3 = tempc; - } - - /* Points are now order so that t_1 is the highest point, t_2 is the - middle point, and t_3 is the lowest point */ - - /* Check for degenerate cases here */ - - if ((ty1 == ty2) && (ty2 == ty3)) { - - /* Points are aligned horizontally. Handle as a special case */ - /* Just draw three lines using the outline color */ - - if (tx2 > tx1) - Plot3D_horizontalinterp(p3,tx1,tx2,ty1,tz1,tz2,c1,c2); - else - Plot3D_horizontalinterp(p3,tx2,tx1,ty1,tz2,tz1,c2,c1); - if (tx3 > tx1) - Plot3D_horizontalinterp(p3,tx1,tx3,ty1,tz1,tz3,c1,c3); - else - Plot3D_horizontalinterp(p3,tx3,tx1,ty1,tz3,tz1,c3,c1); - if (tx3 > tx2) - Plot3D_horizontalinterp(p3,tx2,tx3,ty2,tz2,tz3,c2,c3); - else - Plot3D_horizontalinterp(p3,tx3,tx2,ty2,tz3,tz2,c3,c2); - - } else { - - /* First process line segments between (x1,y1)-(x2,y2) - And between (x1,y1),(x3,y3) */ - - if (ty2 < ty1) { - m1 = (double) (tx2 - tx1)/(double) (ty2 - ty1); - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - mz1 = (tz2 - tz1)/(double) (ty2 - ty1); - mz2 = (tz3 - tz1)/(double) (ty3 - ty1); - mc1 = (c2 - c1)/(double) (ty2 - ty1); - mc2 = (c3 - c1)/(double) (ty3 - ty1); - - y = ty1; - while (y >= ty2) { - /* Calculate x values from slope */ - ix1 = (int) (m1*(y-ty1)+0.5) + tx1; - ix2 = (int) (m2*(y-ty1)+0.5) + tx1; - zz1 = mz1*(y-ty1) + tz1; - zz2 = mz2*(y-ty1) + tz1; - ic1 = mc1*(y-ty1) + c1; - ic2 = mc2*(y-ty1) + c1; - if (ix1 > ix2) - Plot3D_horizontalinterp(p3,ix2,ix1,y,zz2,zz1,ic2,ic1); - else - Plot3D_horizontalinterp(p3,ix1,ix2,y,zz1,zz2,ic1,ic2); - y--; - } - } - if (ty3 < ty2) { - /* Draw lower half of the triangle */ - m2 = (double) (tx3 - tx1)/(double) (ty3 - ty1); - mz2 = (tz3 - tz1)/(double) (ty3 - ty1); - mc2 = (c3 - c1)/(double) (ty3 - ty1); - m3 = (double) (tx3 - tx2)/(double)(ty3 - ty2); - mz3 = (tz3 - tz2)/(double) (ty3 - ty2); - mc3 = (c3 - c2)/(double) (ty3 - ty2); - y = ty2; - while (y >= ty3) { - ix1 = (int) (m3*(y-ty2)+0.5)+tx2; - ix2 = (int) (m2*(y-ty1)+0.5)+tx1; - zz1 = mz3*(y-ty2)+tz2; - zz2 = mz2*(y-ty1)+tz1; - ic1 = mc3*(y-ty2)+c2; - ic2 = mc2*(y-ty1)+c1; - if (ix1 > ix2) - Plot3D_horizontalinterp(p3,ix2,ix1,y,zz2,zz1,ic2,ic1); - else - Plot3D_horizontalinterp(p3,ix1,ix2,y,zz1,zz2,ic1,ic2); - y--; - } - } - } -} - -/* ------------------------------------------------------------------------- - Plot3D_interptriangle(Plot3D *p3, - double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3) - - This function draws a 3D z-buffered filled triangle with color - interpolation. - - This function simply transforms the given points and calls - Plot3D_InterpTriangleTransform(). - -------------------------------------------------------------------------- */ - -void Plot3D_interptriangle(Plot3D *p3, - double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3) { - - int tx1, tx2, tx3, ty1, ty2, ty3; - Zvalue tz1, tz2, tz3; - GL_Vector t; - double invw; - - /* Transform the three points into screen coordinates */ - - Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz1 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz2 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz3 = (Zvalue) t.z; - - Plot3D_interptriangletransform(p3,tx1,ty1,tz1,c1,tx2,ty2,tz2,c2,tx3,ty3,tz3,c3); -} - -/* ------------------------------------------------------------------------- - Plot3D_quad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel fillcolor) - - This function draws a 3D outlined Quadralateral. Used primarily for - drawing meshes and other things. - - Plotting is done in the following order : - (x1,y1,z1) --> (x2,y2,z2) - (x2,y2,z2) --> (x3,y3,z3) - (x3,y3,z3) --> (x4,y4,z4) - (x4,y4,z4) --> (x1,y1,z1) - -------------------------------------------------------------------------- */ - -void Plot3D_quad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color) { - - int tx1, tx2, tx3, tx4, ty1, ty2, ty3, ty4; - Zvalue tz1, tz2, tz3, tz4; - GL_Vector t; - double invw; - - /* Transform the three points into screen coordinates */ - - Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz1 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz2 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz3 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x4,y4,z4,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx4 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty4 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz4 = (Zvalue) t.z; - - Plot3D_linetransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,color); - Plot3D_linetransform(p3,tx2,ty2,tz2,tx3,ty3,tz3,color); - Plot3D_linetransform(p3,tx3,ty3,tz3,tx4,ty4,tz4,color); - Plot3D_linetransform(p3,tx4,ty4,tz4,tx1,ty1,tz1,color); - -} - - -/* ------------------------------------------------------------------------- - Plot3D_solidquad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel fillcolor) - - This function draws a 3D solid Quadralateral. Uses the function - Plot3D_SolidTriangleTransform() to fill in the region. - - Plotting is done in the following order : - (x1,y1,z1) --> (x2,y2,z2) - (x2,y2,z2) --> (x3,y3,z3) - (x3,y3,z3) --> (x4,y4,z4) - (x4,y4,z4) --> (x1,y1,z1) - -------------------------------------------------------------------------- */ - -void Plot3D_solidquad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color) { - - int tx1, tx2, tx3, tx4, ty1, ty2, ty3, ty4; - Zvalue tz1, tz2, tz3, tz4; - GL_Vector t; - double invw; - - /* Transform the three points into screen coordinates */ - - Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz1 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz2 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz3 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x4,y4,z4,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx4 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty4 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz4 = (Zvalue) t.z; - - Plot3D_solidtriangletransform(p3,tx1,ty1,tz1,tx2,ty2,tz2,tx3,ty3,tz3,color); - Plot3D_solidtriangletransform(p3,tx1,ty1,tz1,tx4,ty4,tz4,tx3,ty3,tz3,color); -} - -/* ------------------------------------------------------------------------- - Plot3D_interpquad(Plot3D *p3, double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3, - double x4, double y4, double z4, Pixel c4) - - This function draws a 3D color-interpolated Quadralateral. Uses the function - Plot3D_InterpTriangleTransform() to fill in the region. - - Plotting is done in the following order : - (x1,y1,z1) --> (x2,y2,z2) - (x2,y2,z2) --> (x3,y3,z3) - (x3,y3,z3) --> (x4,y4,z4) - (x4,y4,z4) --> (x1,y1,z1) - -------------------------------------------------------------------------- */ - -void Plot3D_interpquad(Plot3D *p3, double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3, - double x4, double y4, double z4, Pixel c4) { - - - int tx1, tx2, tx3, tx4, ty1, ty2, ty3, ty4; - Zvalue tz1, tz2, tz3, tz4; - GL_Vector t; - double invw; - - /* Transform the three points into screen coordinates */ - - Matrix_transform4(p3->trans_mat,x1,y1,z1,1,&t); /* Point 1 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx1 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty1 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz1 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x2,y2,z2,1,&t); /* Point 2 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx2 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty2 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz2 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x3,y3,z3,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx3 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty3 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz3 = (Zvalue) t.z; - - Matrix_transform4(p3->trans_mat,x4,y4,z4,1,&t); /* Point 3 */ - invw = 1.0/t.w; - t.x = t.x *invw; - t.y = t.y *invw; - t.z = t.z *invw; - tx4 = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty4 = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz4 = (Zvalue) t.z; - - Plot3D_interptriangletransform(p3,tx1,ty1,tz1,c1,tx2,ty2,tz2,c2,tx3,ty3,tz3,c3); - Plot3D_interptriangletransform(p3,tx1,ty1,tz1,c1,tx4,ty4,tz4,c4,tx3,ty3,tz3,c3); - -} - -/* -------------------------------------------------------------------------- - Plot3D_solidsphere(Plot3 *p3, double x, double y, double z, double radius, - Pixel c) - - Makes a 3D sphere at x,y,z with given radius and color. - - Basic strategy : - 1. Transform point to screen coordinates - 2. Figure out what the radius is in screen coordinates - 3. Use bresenham algorithm for large spheres - 4. Use bitmaps for small spheres - -------------------------------------------------------------------------- */ - -/* This is used to fill in spheres */ -static int s_xmin; -static int s_ymin; -static int s_xmax; -static int s_ymax; -static Pixel **s_pixels; -static Zvalue **s_zbuffer; - -void Plot3D_spherehorizontal(int xmin, int xmax, int y, Zvalue z, Pixel color) { - int i; - int startx, endx; - Pixel *p; - Zvalue *zbuf; - - if ((y < s_ymin) || (y >= s_ymax)) return; - if (xmin < s_xmin) startx = s_xmin; - else startx = xmin; - if (xmax >= s_xmax) endx = s_xmax - 1; - else endx = xmax; - - /* Draw it */ - - p = &s_pixels[y][xmin]; - zbuf = &s_zbuffer[y][xmin]; - for (i = startx; i <= endx; i++, p++, zbuf++) { - if (z <= *zbuf) { - *p = color; - *zbuf = z; - } - } -} - -void Plot3D_solidsphere(Plot3D *p3, double x, double y, double z, double radius, - Pixel c) { - - GL_Vector t,r; - double rad; - int tx,ty, irad; - Zvalue tz; - double invw; - int ix, iy, ix1,ix2,p; - FrameBuffer *f; - - /* First transform the point into model coordinates */ - - Matrix_transform4(p3->fullmodel_mat,x,y,z,1,&t); - - /* Now transform two points in order to find proper sphere radius */ - - Matrix_transform4(p3->view_mat,t.x+radius,t.y,t.z,t.w,&r); /* transform radius */ - Matrix_transform4(p3->view_mat,t.x,t.y,t.z,t.w,&t); - - invw = 1.0/t.w; - t.x = t.x*invw; - t.y = t.y*invw; - t.z = t.z*invw; - invw = 1.0/r.w; - r.x = r.x*invw; - r.y = r.y*invw; - r.z = r.z*invw; - invw = 1.0/r.w; - - rad = fabs(t.x - r.x); - - /* Transform everything into screen coordinates */ - - tx = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz = (Zvalue) t.z; - irad = (int) (p3->zoom*(rad*p3->width + 0.5)); - - /* This is only a temporary solution (maybe). */ - -#define fill_zcircle(x,y,c) \ - ix1 = tx - x; \ - ix2 = tx + x; \ - if (ix1 < s_xmin) ix1 = s_xmin; \ - if (ix2 >= s_xmax) ix2 = s_xmax; \ - Plot3D_spherehorizontal(ix1,ix2,y,tz,c); - - f = p3->frame; - s_xmin = f->xmin; - s_ymin = f->ymin; - s_xmax = f->xmax; - s_ymax = f->ymax; - s_pixels = f->pixels; - s_zbuffer = f->zbuffer; - if (irad <= 1) { - /* Plot a single pixel */ - if ((tx >= f->xmin) && (tx < f->xmax)) { - if ((ty >= f->ymin) && (ty ymax)) { - if (tz <= f->zbuffer[ty][tx]) { - f->pixels[ty][tx] = c; - f->zbuffer[ty][tx] = tz; - } - } - } - return; - } - ix = 0; - iy = irad; - p = 3-2*irad; - while (ix <= iy) { - fill_zcircle(ix,ty+iy,c); - fill_zcircle(ix,ty-iy,c); - fill_zcircle(iy,ty+ix,c); - fill_zcircle(iy,ty-ix,c); - if (p < 0) p = p + 4*ix + 6; - else { - p = p + 4*(ix-iy) + 10; - iy = iy -1; - } - ix++; - } -} - - -/* -------------------------------------------------------------------- - Plot3D_outlinesphere(Plot3D *p3, double x, double y, double z, - double radius, Pixel color, Pixel bc) - - Draws an outlined sphere. - -------------------------------------------------------------------- */ - -void Plot3D_outlinesphere(Plot3D *p3, double x, double y, double z, - double radius, Pixel c, Pixel bc) -{ - GL_Vector t,r; - double rad; - int tx,ty, irad; - Zvalue tz; - double invw; - int ix, iy, ix1,ix2,p; - - FrameBuffer *f; - - /* First transform the point into model coordinates */ - - Matrix_transform4(p3->fullmodel_mat,x,y,z,1,&t); - - /* Now transform two points in order to find proper sphere radius */ - - Matrix_transform4(p3->view_mat,t.x+radius,t.y,t.z,t.w,&r); /* transform radius */ - Matrix_transform4(p3->view_mat,t.x,t.y,t.z,t.w,&t); - - invw = 1.0/t.w; - t.x = t.x*invw; - t.y = t.y*invw; - t.z = t.z*invw; - invw = 1.0/r.w; - r.x = r.x*invw; - r.y = r.y*invw; - r.z = r.z*invw; - invw = 1.0/r.w; - - rad = fabs(t.x - r.x); - - /* Transform everything into screen coordinates */ - - tx = (int) ((t.x +p3->xshift)*p3->zoom*p3->width + 0.5) + p3->view_xmin; - ty = (int) ((t.y +p3->yshift)*p3->zoom*p3->height + 0.5) + p3->view_ymin; - tz = (Zvalue) t.z; - irad = (int) (p3->zoom*(rad*p3->width + 0.5)); - - /* This is only a temporary solution (maybe). */ -#define plot_zcircle(x,y,c) \ - if ((x >= s_xmin) && (x < s_xmax) && \ - (y >= s_ymin) && (y < s_ymax)) {\ - if (tz <= s_zbuffer[y][x]) { \ - s_pixels[y][x] = c; \ - s_zbuffer[y][x] = tz; } \ - } - - f = p3->frame; - s_xmin = f->xmin; - s_ymin = f->ymin; - s_xmax = f->xmax; - s_ymax = f->ymax; - s_pixels = f->pixels; - s_zbuffer = f->zbuffer; - - if (irad <= 1) { - /* Plot a single pixel */ - if ((tx >= f->xmin) && (tx < f->xmax)) { - if ((ty >= f->ymin) && (ty ymax)) { - if (tz <= f->zbuffer[ty][tx]) { - f->pixels[ty][tx] = c; - f->zbuffer[ty][tx] = tz; - } - } - } - return; - } - ix = 0; - iy = irad; - p = 3-2*irad; - while (ix <= iy) { - fill_zcircle(ix,ty+iy,c); - fill_zcircle(ix,ty-iy,c); - fill_zcircle(iy,ty+ix,c); - fill_zcircle(iy,ty-ix,c); - - plot_zcircle(tx+ix,ty+iy,bc); - plot_zcircle(tx-ix,ty+iy,bc); - plot_zcircle(tx+ix,ty-iy,bc); - plot_zcircle(tx-ix,ty-iy,bc); - plot_zcircle(tx+iy,ty+ix,bc); - plot_zcircle(tx-iy,ty+ix,bc); - plot_zcircle(tx+iy,ty-ix,bc); - plot_zcircle(tx-iy,ty-ix,bc); - if (p < 0) p = p + 4*ix + 6; - else { - p = p + 4*(ix-iy) + 10; - iy = iy -1; - } - ix++; - } -} - -/* QUAD Test - Test out quad functions for graphing */ - -double zf(double x, double y) { - return cos(sqrt(x*x + y*y)*10.0)/(sqrt(x*x+y*y)+1); -} - -void Quad_Test(Plot3D *p3, int npoints) { - int i,j; - double dx; - double x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,za; - int c; - dx = 2.0/npoints; - - - for (i = 0; i < npoints; i++) - for (j = 0; j < npoints; j++) { - x1 = i*dx + -1.0; - y1 = j*dx + -1.0; - x2 = x1 + dx; - x3 = x1 + dx; - x4 = x1; - y2 = y1; - y3 = y1 + dx; - y4 = y1 + dx; - z1 = zf(x1,y1); - z2 = zf(x2,y2); - z3 = zf(x3,y3); - z4 = zf(x4,y4); - za = 0.25*(z1+z2+z3+z4); - c = 16+((za + 1)*120); - if (c > 254) c = 254; - Plot3D_quad(p3,x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,(Pixel) c); - } -} - - -void Quad_SolidTest(Plot3D *p3, int npoints) { - int i,j; - double dx; - double x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,za; - int c; - dx = 2.0/npoints; - - - for (i = 0; i < npoints; i++) - for (j = 0; j < npoints; j++) { - x1 = i*dx + -1.0; - y1 = j*dx + -1.0; - x2 = x1 + dx; - x3 = x1 + dx; - x4 = x1; - y2 = y1; - y3 = y1 + dx; - y4 = y1 + dx; - z1 = zf(x1,y1); - z2 = zf(x2,y2); - z3 = zf(x3,y3); - z4 = zf(x4,y4); - za = 0.25*(z1+z2+z3+z4); - c = 16+((za + 1)*120); - if (c > 254) c = 254; - Plot3D_solidquad(p3,x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4,(Pixel) c); - } -} - - - -void Quad_InterpTest(Plot3D *p3, int npoints) { - int i,j; - double dx; - double x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4; - int c1,c2,c3,c4; - dx = 2.0/npoints; - - - for (i = 0; i < npoints; i++) - for (j = 0; j < npoints; j++) { - x1 = i*dx + -1.0; - y1 = j*dx + -1.0; - x2 = x1 + dx; - x3 = x1 + dx; - x4 = x1; - y2 = y1; - y3 = y1 + dx; - y4 = y1 + dx; - z1 = zf(x1,y1); - z2 = zf(x2,y2); - z3 = zf(x3,y3); - z4 = zf(x4,y4); - c1 = 16+((z1 + 1)*120); - c2 = 16+((z2 + 1)*120); - c3 = 16+((z3 + 1)*120); - c4 = 16+((z4 + 1)*120); - if (c1 > 254) c1 = 254; - if (c2 > 254) c2 = 254; - if (c3 > 254) c3 = 254; - if (c4 > 254) c4 = 254; - Plot3D_interpquad(p3,x1,y1,z1,(Pixel) c1,x2,y2,z2,(Pixel) c2,x3,y3,z3,(Pixel) c3,x4,y4,z4,(Pixel) c4); - } -} - - - - - - - - - - - - diff --git a/Examples/GIFPlot/Makefile.in b/Examples/GIFPlot/Makefile.in deleted file mode 100644 index 4e51360c8..000000000 --- a/Examples/GIFPlot/Makefile.in +++ /dev/null @@ -1,23 +0,0 @@ -prefix = @prefix@ -exec_prefix = @exec_prefix@ -RANLIB = @RANLIB@ -OPT = - -INSTALL = ../install-sh -c -INSTALL_DATA = ${INSTALL} -m 644 -SHELL = /bin/sh - -all: - cd Lib && $(MAKE) OPT="$(OPT)" - -install: - $(INSTALL_DATA) Include/gifplot.h $(prefix)/include/gifplot.h - $(INSTALL_DATA) libgifplot.a $(exec_prefix)/lib/libgifplot.a - $(RANLIB) $(exec_prefix)/lib/libgifplot.a - -clean:: - rm -f *.@OBJEXT@ *~ libgifplot.a *_wrap* *_man* - cd Lib && $(MAKE) clean - rm -f config.log config.status config.cache - -check: all diff --git a/Examples/GIFPlot/Ocaml/check.list b/Examples/GIFPlot/Ocaml/check.list deleted file mode 100644 index e75ee586a..000000000 --- a/Examples/GIFPlot/Ocaml/check.list +++ /dev/null @@ -1,3 +0,0 @@ -# see top-level Makefile.in -full -simple diff --git a/Examples/GIFPlot/Ocaml/full/Makefile b/Examples/GIFPlot/Ocaml/full/Makefile deleted file mode 100644 index 4f35c43f9..000000000 --- a/Examples/GIFPlot/Ocaml/full/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Include -SRCS = -TARGET = gifcaml -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -lm -INCLUDES = -I../../Include -MLFILE = gifplot.ml -IOBJS = runme.cmo -PROGFILE = runme.ml - -all:: static - -static:: - $(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \ - IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \ - SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_static - -dynamic:: - $(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \ - IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \ - SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_dynamic - -clean:: - $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Ocaml/full/README b/Examples/GIFPlot/Ocaml/full/README deleted file mode 100644 index 4a2b400b5..000000000 --- a/Examples/GIFPlot/Ocaml/full/README +++ /dev/null @@ -1,8 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The ocaml program 'runme.ml' does something a little more -interesting. You'll have to go look at the header file to get a complete -listing of the functions. - - - - diff --git a/Examples/GIFPlot/Ocaml/full/cmap b/Examples/GIFPlot/Ocaml/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC C_float x) - [ x ; y ; z1 ; - (x +. dx) ; y ; z2 ; - (x +. dx) ; (y +. dy) ; z3 ; - x ; (y +. dx) ; z4 ; - (float_of_int (c + 16)) ]))) ; - y_loop (y +. dy) (j + 1) - end in - begin - y_loop ymin 0 ; - x_loop (x +. dx) (i + 1) - end - end in - x_loop xmin 0 - end - -let _ = print_endline "Making a nice 3D plot..." -let _ = drawsolid () - -let _ = _FrameBuffer_writeGIF (C_list [ frame ; cmap ; C_string "image.gif" ]) -let _ = print_endline "Write image.gif" diff --git a/Examples/GIFPlot/Ocaml/simple/Makefile b/Examples/GIFPlot/Ocaml/simple/Makefile deleted file mode 100644 index 50492efc7..000000000 --- a/Examples/GIFPlot/Ocaml/simple/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Include -SRCS = -TARGET = gifsimple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -lm -INCLUDES = -I../../Include -MLFILE = simple.ml -IOBJS = simple_wrap.o simple.cmo runme.cmo -PROGFILE = runme.ml - -all:: static - -static:: - $(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \ - IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \ - SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_static - -dynamic:: - $(MAKE) -f $(TOP)/Makefile TOP='$(TOP)' \ - IOBJS='$(IOBJS)' PROGFILE='$(PROGFILE)' \ - SRCS='$(SRCS)' SWIG='$(SWIG)' MLFILE='$(MLFILE)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ocaml_static - -clean:: - $(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Ocaml/simple/cmap b/Examples/GIFPlot/Ocaml/simple/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239) { $c = 239; } - Plot3D_solidquad($p3,$x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16); - $y = $y + $dy; - } - $x = $x + $dx; - } -} - -print "Making a nice 3D plot...\n"; -drawsolid(); - -FrameBuffer_writeGIF($frame,$cmap,"image.gif"); -print "Wrote image.gif\n"; - diff --git a/Examples/GIFPlot/Perl5/shadow/Makefile b/Examples/GIFPlot/Perl5/shadow/Makefile deleted file mode 100644 index c39eac52c..000000000 --- a/Examples/GIFPlot/Perl5/shadow/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -outcurrentdir -SRCS = -TARGET = gifplot -INTERFACEDIR = ../../Interface/ -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -lm -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' perl5 - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myperl' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' perl5_static - -clean:: - $(MAKE) -f $(TOP)/Makefile perl5_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Perl5/shadow/README b/Examples/GIFPlot/Perl5/shadow/README deleted file mode 100644 index ab12e344e..000000000 --- a/Examples/GIFPlot/Perl5/shadow/README +++ /dev/null @@ -1,2 +0,0 @@ -This example use the file in ../../Interface/gifplot.i to build -an interface with shadow classes. Run the script 'runme.pl'. diff --git a/Examples/GIFPlot/Perl5/shadow/cmap b/Examples/GIFPlot/Perl5/shadow/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9ICclear($BLACK); - -$p3 = new gifplot::Plot3D($frame,$xmin,$ymin,$zmin,$xmax,$ymax,$zmax); -$p3->lookat(2*($zmax-$zmin)); -$p3->autoperspective(40); -$p3->rotu(60); -$p3->rotr(30); -$p3->rotd(10); - -sub drawsolid { - $p3->clear($BLACK); - $p3->start(); - my $dx = 1.0*($xmax-$xmin)/$nxpoints; - my $dy = 1.0*($ymax-$ymin)/$nypoints; - my $cscale = 240.0/($zmax-$zmin); - my $x = $xmin; - for ($i = 0; $i < $nxpoints; $i++) { - my $y = $ymin; - for ($j = 0; $j < $nypoints; $j++) { - my $z1 = func($x,$y); - my $z2 = func($x+$dx,$y); - my $z3 = func($x+$dx,$y+$dy); - my $z4 = func($x,$y+$dy); - my $c1 = $cscale*($z1-$zmin); - my $c2 = $cscale*($z2-$zmin); - my $c3 = $cscale*($z3-$zmin); - my $c4 = $cscale*($z4-$zmin); - my $c = ($c1+$c2+$c3+$c4)/4; - if ($c < 0) { $c = 0; } - if ($c > 239) { $c = 239; } - $p3->solidquad($x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16); - $y = $y + $dy; - } - $x = $x + $dx; - } -} - -print "Making a nice 3D plot...\n"; -drawsolid(); - -$frame->writeGIF($cmap,"image.gif"); -print "Wrote image.gif\n"; - diff --git a/Examples/GIFPlot/Perl5/simple/Makefile b/Examples/GIFPlot/Perl5/simple/Makefile deleted file mode 100644 index 36a8fa938..000000000 --- a/Examples/GIFPlot/Perl5/simple/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -SRCS = -TARGET = simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static - -clean:: - $(MAKE) -f $(TOP)/Makefile perl5_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Perl5/simple/README b/Examples/GIFPlot/Perl5/simple/README deleted file mode 100644 index c2c799a70..000000000 --- a/Examples/GIFPlot/Perl5/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -This is a very minimalistic example in which just a few functions -and constants from library are wrapped and used to draw some simple -shapes. The script 'runme.pl' runs the example. - - diff --git a/Examples/GIFPlot/Perl5/simple/runme.pl b/Examples/GIFPlot/Perl5/simple/runme.pl deleted file mode 100644 index f28255e7c..000000000 --- a/Examples/GIFPlot/Perl5/simple/runme.pl +++ /dev/null @@ -1,28 +0,0 @@ -# Draw some simple shapes -print "Drawing some basic shapes\n"; - -use simple; - -$cmap = simple::new_ColorMap(); -$f = simple::new_FrameBuffer(400,400); - -# Clear the picture -simple::FrameBuffer_clear($f,$simple::BLACK); - -# Make a red box -simple::FrameBuffer_box($f,40,40,200,200,$simple::RED); - -# Make a blue circle -simple::FrameBuffer_circle($f,200,200,40,$simple::BLUE); - -# Make green line -simple::FrameBuffer_line($f,10,390,390,200, $simple::GREEN); - -# Write an image out to disk - -simple::FrameBuffer_writeGIF($f,$cmap,"image.gif"); -print "Wrote image.gif\n"; - -simple::delete_FrameBuffer($f); -simple::delete_ColorMap($cmap); - diff --git a/Examples/GIFPlot/Perl5/simple/simple.i b/Examples/GIFPlot/Perl5/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Perl5/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/GIFPlot/Php/check.list b/Examples/GIFPlot/Php/check.list deleted file mode 100644 index e75ee586a..000000000 --- a/Examples/GIFPlot/Php/check.list +++ /dev/null @@ -1,3 +0,0 @@ -# see top-level Makefile.in -full -simple diff --git a/Examples/GIFPlot/Php/full/Makefile b/Examples/GIFPlot/Php/full/Makefile deleted file mode 100644 index e33e7a730..000000000 --- a/Examples/GIFPlot/Php/full/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Include -noproxy -SRCS = -TARGET = php_gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -lm -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php - -clean:: - $(MAKE) -f $(TOP)/Makefile php_clean - rm -f *.gif - rm -f php_gifplot.h - -check: all diff --git a/Examples/GIFPlot/Php/full/README b/Examples/GIFPlot/Php/full/README deleted file mode 100644 index f8d38d9af..000000000 --- a/Examples/GIFPlot/Php/full/README +++ /dev/null @@ -1,4 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The script 'runme.php3' does something a little more -interesting. You'll have to go look at the header file to get a complete -listing of the functions. diff --git a/Examples/GIFPlot/Php/full/cmap b/Examples/GIFPlot/Php/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239) { $c = 239; } - Plot3D_solidquad($p3, $x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16); - $y = $y + $dy; - } - $x = $x + $dx; - } -} - -print "Making a nice 3D plot...\n"; -drawsolid(); - -FrameBuffer_writeGIF($frame, $cmap,"image.gif"); -print "Wrote image.gif\n"; - -?> diff --git a/Examples/GIFPlot/Php/shadow/Makefile b/Examples/GIFPlot/Php/shadow/Makefile deleted file mode 100644 index df8ee30c0..000000000 --- a/Examples/GIFPlot/Php/shadow/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface -SRCS = -TARGET = php_gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -lm -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php - -clean:: - $(MAKE) -f $(TOP)/Makefile php_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Php/shadow/README b/Examples/GIFPlot/Php/shadow/README deleted file mode 100644 index 3e91f7d59..000000000 --- a/Examples/GIFPlot/Php/shadow/README +++ /dev/null @@ -1,2 +0,0 @@ -This example use the file in ../../Interface/gifplot.i to build -an interface with shadow classes. Run the script 'runme.php3'. diff --git a/Examples/GIFPlot/Php/shadow/cmap b/Examples/GIFPlot/Php/shadow/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9ICclear(BLACK); - - -$p3 = new Plot3D($frame,$xmin,$ymin,$zmin,$xmax,$ymax,$zmax); -$p3->lookat(2*($zmax-$zmin)); -$p3->autoperspective(40); -$p3->rotu(60); -$p3->rotr(30); -$p3->rotd(10); - -function drawsolid() { - global $xmax; - global $xmin; - global $ymax; - global $ymin; - global $zmin; - global $zmax; - global $nxpoints; - global $nypoints; - global $p3; - - $p3->clear(BLACK); - $p3->start(); - $dx = 1.0*($xmax-$xmin)/$nxpoints; - $dy = 1.0*($ymax-$ymin)/$nypoints; - $cscale = 240.0/($zmax-$zmin); - $x = $xmin; - for ($i = 0; $i < $nxpoints; $i++) { - $y = $ymin; - for ($j = 0; $j < $nypoints; $j++) { - $z1 = func($x,$y); - $z2 = func($x+$dx,$y); - $z3 = func($x+$dx,$y+$dy); - $z4 = func($x,$y+$dy); - $c1 = $cscale*($z1-$zmin); - $c2 = $cscale*($z2-$zmin); - $c3 = $cscale*($z3-$zmin); - $c4 = $cscale*($z4-$zmin); - $c = ($c1+$c2+$c3+$c4)/4; - if ($c < 0) { $c = 0; } - if ($c > 239) { $c = 239; } - $p3->solidquad($x,$y,$z1,$x+$dx,$y,$z2,$x+$dx,$y+$dy,$z3,$x,$y+$dy,$z4,$c+16); - $y = $y + $dy; - } - $x = $x + $dx; - } -} - -print "Making a nice 3D plot...\n"; -drawsolid(); - -$frame->writeGIF($cmap,"image.gif"); -print "Wrote image.gif\n"; - -?> diff --git a/Examples/GIFPlot/Php/simple/Makefile b/Examples/GIFPlot/Php/simple/Makefile deleted file mode 100644 index e60b641fa..000000000 --- a/Examples/GIFPlot/Php/simple/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -noproxy -SRCS = -TARGET = php_simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php - -clean:: - $(MAKE) -f $(TOP)/Makefile php_clean - rm -f *.gif - rm -f php_simple.h - -check: all diff --git a/Examples/GIFPlot/Php/simple/README b/Examples/GIFPlot/Php/simple/README deleted file mode 100644 index c2c799a70..000000000 --- a/Examples/GIFPlot/Php/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -This is a very minimalistic example in which just a few functions -and constants from library are wrapped and used to draw some simple -shapes. The script 'runme.pl' runs the example. - - diff --git a/Examples/GIFPlot/Php/simple/runme.php b/Examples/GIFPlot/Php/simple/runme.php deleted file mode 100644 index cf21a0927..000000000 --- a/Examples/GIFPlot/Php/simple/runme.php +++ /dev/null @@ -1,32 +0,0 @@ - - diff --git a/Examples/GIFPlot/Php/simple/simple.i b/Examples/GIFPlot/Php/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Php/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/GIFPlot/Pike/check.list b/Examples/GIFPlot/Pike/check.list deleted file mode 100644 index d38998cab..000000000 --- a/Examples/GIFPlot/Pike/check.list +++ /dev/null @@ -1,2 +0,0 @@ -# see top-level Makefile.in -simple diff --git a/Examples/GIFPlot/Pike/simple/Makefile b/Examples/GIFPlot/Pike/simple/Makefile deleted file mode 100644 index d339e0333..000000000 --- a/Examples/GIFPlot/Pike/simple/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -SRCS = -TARGET = simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' pike - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mypike' INTERFACE='$(INTERFACE)' pike_static - -clean:: - $(MAKE) -f $(TOP)/Makefile pike_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Pike/simple/README b/Examples/GIFPlot/Pike/simple/README deleted file mode 100644 index 177b3633b..000000000 --- a/Examples/GIFPlot/Pike/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -This is a very minimalistic example in which just a few functions -and constants from library are wrapped and used to draw some simple -shapes. The script 'runme.pike' runs the example. - - diff --git a/Examples/GIFPlot/Pike/simple/runme.pike b/Examples/GIFPlot/Pike/simple/runme.pike deleted file mode 100644 index 0e70235f1..000000000 --- a/Examples/GIFPlot/Pike/simple/runme.pike +++ /dev/null @@ -1,30 +0,0 @@ -int main() -{ - // Draw some simple shapes - write("Drawing some basic shapes\n"); - - .simple.ColorMap cmap = .simple.new_ColorMap(); - .simple.FrameBuffer f = .simple.new_FrameBuffer(400, 400); - - // Clear the picture - .simple.FrameBuffer_clear(f, .simple.BLACK); - - // Make a red box - .simple.FrameBuffer_box(f, 40, 40, 200, 200, .simple.RED); - - // Make a blue circle - .simple.FrameBuffer_circle(f, 200, 200, 40, .simple.BLUE); - - // Make green line - .simple.FrameBuffer_line(f, 10, 390, 390, 200, .simple.GREEN); - - // Write an image out to disk - .simple.FrameBuffer_writeGIF(f, cmap, "image.gif"); - write("Wrote image.gif\n"); - - .simple.delete_FrameBuffer(f); - .simple.delete_ColorMap(cmap); - - return 0; -} - diff --git a/Examples/GIFPlot/Pike/simple/simple.i b/Examples/GIFPlot/Pike/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Pike/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/GIFPlot/Python/check.list b/Examples/GIFPlot/Python/check.list deleted file mode 100644 index 13de977af..000000000 --- a/Examples/GIFPlot/Python/check.list +++ /dev/null @@ -1,4 +0,0 @@ -# see top-level Makefile.in -full -shadow -simple diff --git a/Examples/GIFPlot/Python/full/Makefile b/Examples/GIFPlot/Python/full/Makefile deleted file mode 100644 index 83a7c864b..000000000 --- a/Examples/GIFPlot/Python/full/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../preinst-swig -SWIGOPT = -I../../Include -SRCS = -TARGET = gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mypython' INTERFACE='$(INTERFACE)' python_static - -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - rm -f *.gif - -check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/full/README b/Examples/GIFPlot/Python/full/README deleted file mode 100644 index 52971e40a..000000000 --- a/Examples/GIFPlot/Python/full/README +++ /dev/null @@ -1,8 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The script 'runme.py' does something a little more -interesting. You'll have to go look at the header file to get a complete -listing of the functions. - - - - diff --git a/Examples/GIFPlot/Python/full/cmap b/Examples/GIFPlot/Python/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239 : c = 239 - Plot3D_solidquad(p3,x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,c+16) - y = y + dy - x = x + dx - -print "Making a nice 3D plot..." -drawsolid() - -FrameBuffer_writeGIF(frame,cmap,"image.gif") -print "Wrote image.gif" - diff --git a/Examples/GIFPlot/Python/shadow/Makefile b/Examples/GIFPlot/Python/shadow/Makefile deleted file mode 100644 index 3ae9a9897..000000000 --- a/Examples/GIFPlot/Python/shadow/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../preinst-swig -SWIGOPT = -outcurrentdir -SRCS = -TARGET = gifplot -INTERFACEDIR = ../../Interface/ -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' python - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mypython' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' python_static - -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - rm -f *.gif - -check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/shadow/README b/Examples/GIFPlot/Python/shadow/README deleted file mode 100644 index aa761e240..000000000 --- a/Examples/GIFPlot/Python/shadow/README +++ /dev/null @@ -1,8 +0,0 @@ -This example illustrates Python shadow classes. Take a look at -the file GIFPlot/Interface/gifplot.i - - - - - - diff --git a/Examples/GIFPlot/Python/shadow/cmap b/Examples/GIFPlot/Python/shadow/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239 : c = 239 - p3.solidquad(x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,c+16) - y = y + dy - x = x + dx - -print "Making a nice 3D plot..." -drawsolid() - -frame.writeGIF(cmap,"image.gif") -print "Wrote image.gif" - diff --git a/Examples/GIFPlot/Python/simple/Makefile b/Examples/GIFPlot/Python/simple/Makefile deleted file mode 100644 index 9fc9a6c72..000000000 --- a/Examples/GIFPlot/Python/simple/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../preinst-swig -SWIGOPT = -SRCS = -TARGET = simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mypython' INTERFACE='$(INTERFACE)' python_static - -clean:: - $(MAKE) -f $(TOP)/Makefile python_clean - rm -f $(TARGET).py - rm -f *.gif - -check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/simple/README b/Examples/GIFPlot/Python/simple/README deleted file mode 100644 index 22152c665..000000000 --- a/Examples/GIFPlot/Python/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -This is a very minimalistic example in which just a few functions -and constants from library are wrapped and used to draw some simple -shapes. The script 'runme.py' runs the example. - - diff --git a/Examples/GIFPlot/Python/simple/runme.py b/Examples/GIFPlot/Python/simple/runme.py deleted file mode 100644 index dade67767..000000000 --- a/Examples/GIFPlot/Python/simple/runme.py +++ /dev/null @@ -1,27 +0,0 @@ -# Draw some simple shapes -print "Drawing some basic shapes" -import simple - -cmap = simple.new_ColorMap() -f = simple.new_FrameBuffer(400,400) - -# Clear the picture -simple.FrameBuffer_clear(f,simple.BLACK) - -# Make a red box -simple.FrameBuffer_box(f,40,40,200,200,simple.RED) - -# Make a blue circle -simple.FrameBuffer_circle(f,200,200,40,simple.BLUE) - -# Make green line -simple.FrameBuffer_line(f,10,390,390,200, simple.GREEN) - -# Write an image out to disk - -simple.FrameBuffer_writeGIF(f,cmap,"image.gif") -print "Wrote image.gif" - -simple.delete_FrameBuffer(f) -simple.delete_ColorMap(cmap) - diff --git a/Examples/GIFPlot/Python/simple/simple.i b/Examples/GIFPlot/Python/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Python/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/GIFPlot/README b/Examples/GIFPlot/README deleted file mode 100644 index ac1025a42..000000000 --- a/Examples/GIFPlot/README +++ /dev/null @@ -1,59 +0,0 @@ -GIFPlot -======= - -To illustrate various SWIG features, the following examples involve -building an interface to a small, but somewhat useful graphics library -for creating 2D and 3D images in the form of GIF files. The Perl, -Python, Tcl, Java, Ruby etc. directories contain various examples specific to -those languages. - -This library was originally developed as part of the SPaSM molecular -dynamics project at Los Alamos National Laboratory. However, due to -patent enforcement issues related to LZW encoding and a general lack -of time on the part of the author, the library was never officially -released. On the plus side, a number of people have found it to be a -useful easter egg within the SWIG distribution :-). - - -DUE TO PATENT RESTRICTIONS ON THE LZW COMPRESSION ALGORITHM, THIS -LIBRARY ONLY PRODUCES UNCOMPRESSED GIF FILES. SO THERE. - - -Building the Library -==================== - -In order to run the examples, it is first necessary to build the GIFPlot -C library. To do this, simply run make: - - make - -Running the Examples -==================== - -Once the library has been built, go to your chosen language directory, -that is, Perl, Python, Tcl, Java, Ruby etc. Each example should have a -README file with a description. - -Each example can be compiled using the makefile in each example directory. This -makefile uses the top level makefile in the "Examples" directory of the distribution. -If the example doesn't compile, you will need to adjust the settings in this file. - -Documentation -============= - -Read the source Luke. The examples should be pretty much self-explanatory. -The header file Include/gifplot.h contains the full API. - -The original documentation for the library can be found online at: - - http://www.dabeaz.com/gifplot/index.html - - -Let me know what you think! -=========================== -If you found this example to be useful, confusing, or otherwise, I would like to know -about it. Suggestions for improvement are welcome. - --- Dave (dave@dabeaz.com) - - diff --git a/Examples/GIFPlot/Ruby/check.list b/Examples/GIFPlot/Ruby/check.list deleted file mode 100644 index 13de977af..000000000 --- a/Examples/GIFPlot/Ruby/check.list +++ /dev/null @@ -1,4 +0,0 @@ -# see top-level Makefile.in -full -shadow -simple diff --git a/Examples/GIFPlot/Ruby/full/Makefile b/Examples/GIFPlot/Ruby/full/Makefile deleted file mode 100644 index 5af8bc832..000000000 --- a/Examples/GIFPlot/Ruby/full/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Include -SRCS = -TARGET = gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static - -clean:: - $(MAKE) -f $(TOP)/Makefile ruby_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Ruby/full/README b/Examples/GIFPlot/Ruby/full/README deleted file mode 100644 index 22af6cb06..000000000 --- a/Examples/GIFPlot/Ruby/full/README +++ /dev/null @@ -1,8 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The script 'runme.rb' does something a little more -interesting. You'll have to go look at the header file to get a complete -listing of the functions. - - - - diff --git a/Examples/GIFPlot/Ruby/full/cmap b/Examples/GIFPlot/Ruby/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239 - Plot3D_solidquad(P3,x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,c+16) - y = y + dy - end - x = x + dx - end -end - -puts "Making a nice 3D plot..." -drawsolid() - -FrameBuffer_writeGIF(frame,cmap,"image.gif") -puts "Wrote image.gif" diff --git a/Examples/GIFPlot/Ruby/shadow/Makefile b/Examples/GIFPlot/Ruby/shadow/Makefile deleted file mode 100644 index 8cbea2a57..000000000 --- a/Examples/GIFPlot/Ruby/shadow/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -outcurrentdir -SRCS = -TARGET = gifplot -INTERFACEDIR = ../../Interface/ -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' ruby - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myruby' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' ruby_static - -clean:: - $(MAKE) -f $(TOP)/Makefile ruby_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Ruby/shadow/README b/Examples/GIFPlot/Ruby/shadow/README deleted file mode 100644 index 7a33e137f..000000000 --- a/Examples/GIFPlot/Ruby/shadow/README +++ /dev/null @@ -1,5 +0,0 @@ -This example illustrates Ruby shadow classes. Take a look at -the file GIFPlot/Interface/gifplot.i - -Actually Ruby module of SWIG needs no shadow class. But this example -is named "shadow" in order to be consistent with other languages. diff --git a/Examples/GIFPlot/Ruby/shadow/cmap b/Examples/GIFPlot/Ruby/shadow/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239 - P3.solidquad(x,y,z1,x+dx,y,z2,x+dx,y+dy,z3,x,y+dy,z4,c+16) - y = y + dy - end - x = x + dx - end -end - -puts "Making a nice 3D plot..." -drawsolid() - -frame.writeGIF(cmap,"image.gif") -puts "Wrote image.gif" - diff --git a/Examples/GIFPlot/Ruby/simple/Makefile b/Examples/GIFPlot/Ruby/simple/Makefile deleted file mode 100644 index f7ca1a7d8..000000000 --- a/Examples/GIFPlot/Ruby/simple/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -SRCS = -TARGET = simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static - -clean:: - $(MAKE) -f $(TOP)/Makefile ruby_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Ruby/simple/README b/Examples/GIFPlot/Ruby/simple/README deleted file mode 100644 index 9b51038bf..000000000 --- a/Examples/GIFPlot/Ruby/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -This is a very minimalistic example in which just a few functions -and constants from library are wrapped and used to draw some simple -shapes. The script 'runme.rb' runs the example. - - diff --git a/Examples/GIFPlot/Ruby/simple/runme.rb b/Examples/GIFPlot/Ruby/simple/runme.rb deleted file mode 100644 index e8bf5a40f..000000000 --- a/Examples/GIFPlot/Ruby/simple/runme.rb +++ /dev/null @@ -1,27 +0,0 @@ -# Draw some simple shapes -puts "Drawing some basic shapes" -require 'simple' - -cmap = Simple.new_ColorMap() -f = Simple.new_FrameBuffer(400,400) - -# Clear the picture -Simple.FrameBuffer_clear(f,Simple::BLACK) - -# Make a red box -Simple.FrameBuffer_box(f,40,40,200,200,Simple::RED) - -# Make a blue circle -Simple.FrameBuffer_circle(f,200,200,40,Simple::BLUE) - -# Make green line -Simple.FrameBuffer_line(f,10,390,390,200, Simple::GREEN) - -# Write an image out to disk - -Simple.FrameBuffer_writeGIF(f,cmap,"image.gif") -puts "Wrote image.gif" - -Simple.delete_FrameBuffer(f) -Simple.delete_ColorMap(cmap) - diff --git a/Examples/GIFPlot/Ruby/simple/simple.i b/Examples/GIFPlot/Ruby/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Ruby/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/GIFPlot/Tcl/check.list b/Examples/GIFPlot/Tcl/check.list deleted file mode 100644 index 2b6e3d28a..000000000 --- a/Examples/GIFPlot/Tcl/check.list +++ /dev/null @@ -1,4 +0,0 @@ -# see top-level Makefile.in -full -mandel -simple diff --git a/Examples/GIFPlot/Tcl/full/Makefile b/Examples/GIFPlot/Tcl/full/Makefile deleted file mode 100644 index 0c016e364..000000000 --- a/Examples/GIFPlot/Tcl/full/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Include -SRCS = -TARGET = gifplot -INTERFACE = gifplot.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh - -clean:: - $(MAKE) -f $(TOP)/Makefile tcl_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Tcl/full/README b/Examples/GIFPlot/Tcl/full/README deleted file mode 100644 index bdba4e8b0..000000000 --- a/Examples/GIFPlot/Tcl/full/README +++ /dev/null @@ -1,8 +0,0 @@ -This example runs the entire gifplot.h header file through SWIG without -any changes. The script 'runme.tcl' does something a little more -interesting. You'll have to go look at the header file to get a complete -listing of the functions. - - - - diff --git a/Examples/GIFPlot/Tcl/full/cmap b/Examples/GIFPlot/Tcl/full/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC 239} { set c 239 } - Plot3D_solidquad $p3 $x $y $z1 [expr {$x+$dx}] $y $z2 [expr {$x+$dx}] [expr {$y+$dy}] $z3 $x [expr {$y+$dy}] $z4 [expr {$c+16}] - set y [expr {$y + $dy}] - } - set x [expr {$x + $dx}] - } -} - -puts "Making a nice 3D plot..." -drawsolid - -FrameBuffer_writeGIF $frame $cmap "image.gif" -puts "Wrote image.gif" - diff --git a/Examples/GIFPlot/Tcl/mandel/Makefile b/Examples/GIFPlot/Tcl/mandel/Makefile deleted file mode 100644 index 9280d7bb2..000000000 --- a/Examples/GIFPlot/Tcl/mandel/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface -SRCS = -TARGET = gifplot -INTERFACE = mandel.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mywish' INTERFACE='$(INTERFACE)' wish - -clean:: - $(MAKE) -f $(TOP)/Makefile tcl_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Tcl/mandel/README b/Examples/GIFPlot/Tcl/mandel/README deleted file mode 100644 index a533d09b8..000000000 --- a/Examples/GIFPlot/Tcl/mandel/README +++ /dev/null @@ -1,6 +0,0 @@ -Kill lots of time exploring the Mandelbrot set. This example uses -the full SWIG interface file located in ../../Interface. To run -the program, type 'wish mandel.tcl'. - - - diff --git a/Examples/GIFPlot/Tcl/mandel/cmap b/Examples/GIFPlot/Tcl/mandel/cmap deleted file mode 100644 index a20c331a9573dd8443380680bfe2cc428780d8a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZQzpd(=A5)hSEP}Mdtvvzdz4h)M)OwTDSuW4%Uoiu&!q7`d5@7R0z#JS5i?>&C` z?#s{r^Z@9-XXO?YlTlLFHMX#G@$?UkN=VBFxv-;m^2~WlR;}N<`@pd?7q8!a^y1xT znmh34m-nxpKDd4D;+bOy_iW#^cE#d(Gbi_Tw$xXZ7G$R-M27|XxI5We80l&#%Snpx zbFrd(h8Vt}lCeu@T6xFJRlCpJeMef510DGC$^DyG&YwK8f9IC {BoxBegin %W %x %y} - bind $c {BoxDrag %W %x %y} - bind $c "BoxFinish %W %x %y $p2 $mxmin $mymin $mxmax $mymax $func" -} - -proc BoxBegin {w x y} { - global box - set box(anchor) [list $x $y] - catch {unset box(last)} -} - -proc BoxDrag { w x y} { - global box - catch {$w delete $box(last)} - set box(last) [eval {$w create rect} $box(anchor) {$x $y -tag box -outline white}] -} - -proc BoxFinish {w x y p2 mxmin mymin mxmax mymax func } { - global box - set start $box(anchor) - set x1 [lrange $start 0 0] - set y1 [lrange $start 1 1] - catch {$w delete $box(last)} -# Call the handler function - $func $p2 $mxmin $mymin $mxmax $mymax $x1 $y1 $x $y -} - -proc display_image {filename p2 handler} { - global __imageno __images - set i [image create photo -file $filename] - set tl .image$__imageno - toplevel $tl - frame $tl.img - frame $tl.button - - set width [image width $i] - set height [image height $i] - canvas $tl.img.c -width [expr {$width+0}] -height [expr {$height+0}] - pack $tl.img.c - $tl.img.c create image 0 0 -image $i -anchor nw - label $tl.button.label -text $filename - pack $tl.button.label -side left - button $tl.button.dismiss -text "Dismiss" -command "dismiss $tl $i" -width 10 - pack $tl.button.dismiss -side right - pack $tl.img $tl.button -side top -fill x - BoxInit $tl.img.c $p2 [$p2 cget -xmin] [$p2 cget -ymin] [$p2 cget -xmax] [$p2 cget -ymax] $handler - bind $tl "dismiss $tl $i" - bind $tl "dismiss $tl $i" - - # Bind some actions to the canvas - - incr __imageno 1 -} - -proc test {} { - puts "hello" -} - diff --git a/Examples/GIFPlot/Tcl/mandel/mandel.i b/Examples/GIFPlot/Tcl/mandel/mandel.i deleted file mode 100644 index 0b19f4727..000000000 --- a/Examples/GIFPlot/Tcl/mandel/mandel.i +++ /dev/null @@ -1,47 +0,0 @@ -// Special module to run the mandlebrot set -%module gifplot -%include gifplot.i - -%inline %{ - -void mandel(Plot2D *p2, int tol) { - double scalingx; - double scalingy; - double zr,zi,ztr,zti,cr,ci; - double cscale; - int i,j,n; - FrameBuffer *f; - - f = p2->frame; - scalingx = (p2->xmax-p2->xmin)/f->width; - scalingy = (p2->ymax-p2->ymin)/f->height; - - cscale = 239.0/tol; - printf("working...\n"); - for (i = 0; i < f->width; i++) { - for (j = 0; j < f->height; j++) { - zr = scalingx*i + p2->xmin; - zi = scalingy*j + p2->ymin; - cr = zr; - ci = zi; - n = 0; - while (n < tol) { - ztr = zr*zr-zi*zi + cr; - zti = 2*zr*zi + ci; - zr = ztr; - zi = zti; - if (ztr*ztr + zti*zti > 20) break; - n = n + 1; - } - - if (n >= tol) FrameBuffer_plot(f,i,j,BLACK); - else FrameBuffer_plot(f,i,j,16+(int) (n*cscale)); - } - if ((i % 10) == 0) printf("%d\n",i); - } - -} - -%} - - diff --git a/Examples/GIFPlot/Tcl/mandel/mandel.tcl b/Examples/GIFPlot/Tcl/mandel/mandel.tcl deleted file mode 100644 index 3e1600bc1..000000000 --- a/Examples/GIFPlot/Tcl/mandel/mandel.tcl +++ /dev/null @@ -1,170 +0,0 @@ -catch { load ./gifplot[info sharedlibextension] } -source display.tcl -set tcl_precision 17 -set f [FrameBuffer -args 400 400] -set cmap [ColorMap -args cmap] -set p2 [Plot2D -args $f -3 -2 1 2] - -set xmin -3 -set xmax 1 -set ymin -2.0 -set ymax 2.0 -set tolerance 240 -set filename mandel.gif - -# Make a plot from the above parms - -proc make_plot {} { - global p2 cmap tolerance - global xmin ymin xmax ymax filename - $p2 setrange $xmin $ymin $xmax $ymax - $p2 start - . config -cursor watch - update - mandel $p2 $tolerance - . config -cursor arrow - [$p2 cget -frame] writeGIF $cmap $filename - display_image $filename $p2 set_zoom -} - - -# Take some screen coordinates and set global min and max values - -proc set_zoom {p2 mxmin mymin mxmax mymax x1 y1 x2 y2} { - global xmin ymin xmax ymax - - set frame [$p2 cget -frame] - set width [$frame cget -width] - set height [$frame cget -height] - - if {$x1 < 0} {set x1 0} - if {$x1 > ($width)} {set x1 $width} - if {$x2 < 0} {set x2 0} - if {$x2 > ($width)} {set x2 $width} - if {$x1 < $x2} {set ixmin $x1; set ixmax $x2} {set ixmin $x2; set ixmax $x1} - - if {$y1 < 0} {set y1 0} - if {$y1 > ($height)} {set y1 $height} - if {$y2 < 0} {set y2 0} - if {$y2 > ($height)} {set y2 $height} - if {$y1 < $y2} {set iymin $y1; set iymax $y2} {set iymin $y2; set iymax $y1} - - # Now determine new min and max values based on screen location - - set xmin [expr {$mxmin + ($mxmax-$mxmin)*($ixmin)/($width)}] - set xmax [expr {$mxmin + ($mxmax-$mxmin)*($ixmax)/($width)}] - set ymin [expr {$mymin + ($mymax-$mymin)*(($height)-($iymax))/($height)}] - set ymax [expr {$mymin + ($mymax-$mymin)*(($height)-($iymin))/($height)}] - - catch {make_plot} -} - -# Box drag constrained to a square -proc BoxDrag { w x y} { - global box - catch {$w delete $box(last)} - set x1 [lrange $box(anchor) 0 0] - set y1 [lrange $box(anchor) 1 1] - set dx [expr {$x - $x1}] - set dy [expr {$y - $y1}] - if {abs($dy) > abs($dx)} {set dx $dy} - set newx [expr {$x1 + $dx}] - set newy [expr {$y1 + $dx}] - set box(last) [eval {$w create rect} $box(anchor) {$newx $newy -tag box -outline white}] -} - - -proc BoxFinish {w x y p2 mxmin mymin mxmax mymax func } { - global box - set start $box(anchor) - set x1 [lrange $box(anchor) 0 0] - set y1 [lrange $box(anchor) 1 1] - set dx [expr {$x - $x1}] - set dy [expr {$y - $y1}] - if {($dx == 0) || ($dy == 0)} { - catch {$w delete $box(last)} - return - } - if {abs($dy) > abs($dx)} {set dx $dy} - set newx [expr {$x1 + $dx}] - set newy [expr {$y1 + $dx}] - $w config -cursor watch - update -# Call the handler function - $func $p2 $mxmin $mymin $mxmax $mymax $x1 $y1 $newx $newy - catch {$w delete $box(last)} - $w config -cursor arrow -} - - -# Create a few frames - -wm title . Mandelbrot -frame .title -relief groove -borderwidth 1 -label .title.name -text "Mandelbrot Set" -button .title.quit -text "Quit" -command "exit" -button .title.about -text "About" -command "about" -pack .title.name -side left -pack .title.quit .title.about -side right - -frame .func -relief groove -borderwidth 1 - -frame .func.xrange -label .func.xrange.xrlabel -text "X range" -width 12 -entry .func.xrange.xmin -textvar xmin -width 8 -label .func.xrange.xtolabel -text "to" -entry .func.xrange.xmax -textvar xmax -width 8 -pack .func.xrange.xrlabel .func.xrange.xmin .func.xrange.xtolabel .func.xrange.xmax -side left - -frame .func.yrange -label .func.yrange.yrlabel -text "Y range" -width 12 -entry .func.yrange.ymin -textvar ymin -width 8 -label .func.yrange.ytolabel -text "to" -entry .func.yrange.ymax -textvar ymax -width 8 -pack .func.yrange.yrlabel .func.yrange.ymin .func.yrange.ytolabel .func.yrange.ymax -side left - -frame .func.npoints -label .func.npoints.label -text "Tolerance " -width 12 -entry .func.npoints.npoints -textvar tolerance -width 8 -scale .func.npoints.scale -from 0 -to 2500 -variable tolerance -orient horizontal -showvalue false \ - -sliderlength 13 -bigincrement 10 -resolution 10 -pack .func.npoints.label .func.npoints.npoints .func.npoints.scale -side left - -pack .func.xrange .func.yrange .func.npoints -side top -fill x - -# Filename dialog - -frame .save -relief groove -borderwidth 1 - -frame .save.file -label .save.file.label -text "Save as" -width 12 -entry .save.file.filename -textvar filename -width 20 -pack .save.file.label .save.file.filename -side left -pack .save.file -side left -fill x -button .save.go -text "Plot" -command "make_plot" -pack .save.go -side right - -bind .save.file.filename {make_plot} - -pack .title .func .save -side top -fill both - -proc about { } { - toplevel .about -width 350 - - message .about.m -text "\ -Mandelbrot Set\n\n\ -Copyright (c) 1997\n\ -Dave Beazley\n\ -University of Utah\n\n\ -Creates a plot of the Mandelbrot set. Any displayed image can be zoomed by clicking and \ -dragging. Although the main calculation is written in C, it may take awhile for each \ -image to be calculated (be patient). Image quality can be improved at the expense of speed \ -by increasing the tolerance value.\n" - -button .about.okay -text "Ok" -command {destroy .about} - -pack .about.m .about.okay -side top -focus .about.okay -} - -make_plot diff --git a/Examples/GIFPlot/Tcl/simple/Makefile b/Examples/GIFPlot/Tcl/simple/Makefile deleted file mode 100644 index 752d79c10..000000000 --- a/Examples/GIFPlot/Tcl/simple/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -SRCS = -TARGET = simple -INTERFACE = simple.i -LIBS = -L../.. -lgifplot -INCLUDES = -I../../Include - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' tcl - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mytclsh' INTERFACE='$(INTERFACE)' tclsh - -clean:: - $(MAKE) -f $(TOP)/Makefile tcl_clean - rm -f *.gif - -check: all diff --git a/Examples/GIFPlot/Tcl/simple/README b/Examples/GIFPlot/Tcl/simple/README deleted file mode 100644 index d6b291c92..000000000 --- a/Examples/GIFPlot/Tcl/simple/README +++ /dev/null @@ -1,5 +0,0 @@ -This is a very minimalistic example in which just a few functions -and constants from library are wrapped and used to draw some simple -shapes. The script 'runme.tcl' runs the example. - - diff --git a/Examples/GIFPlot/Tcl/simple/runme.tcl b/Examples/GIFPlot/Tcl/simple/runme.tcl deleted file mode 100644 index e3f41266c..000000000 --- a/Examples/GIFPlot/Tcl/simple/runme.tcl +++ /dev/null @@ -1,27 +0,0 @@ -# Draw some simple shapes -puts "Drawing some basic shapes" - -catch { load ./simple[info sharedlibextension] simple} - -set cmap [new_ColorMap] -set f [new_FrameBuffer 400 400] - -# Clear the picture -FrameBuffer_clear $f $BLACK - -# Make a red box -FrameBuffer_box $f 40 40 200 200 $RED - -# Make a blue circle -FrameBuffer_circle $f 200 200 40 $BLUE - -# Make green line -FrameBuffer_line $f 10 390 390 200 $GREEN - -# Write an image out to disk -FrameBuffer_writeGIF $f $cmap image.gif -puts "Wrote image.gif" - -delete_FrameBuffer $f -delete_ColorMap $cmap - diff --git a/Examples/GIFPlot/Tcl/simple/simple.i b/Examples/GIFPlot/Tcl/simple/simple.i deleted file mode 100644 index 457bc4c09..000000000 --- a/Examples/GIFPlot/Tcl/simple/simple.i +++ /dev/null @@ -1,38 +0,0 @@ -/* This example shows a very simple interface wrapping a few - primitive declarations */ - -%module simple -%{ -#include "gifplot.h" -%} - -typedef unsigned char Pixel; - -/* Here are a few useful functions */ - -ColorMap *new_ColorMap(char *filename = 0); -void delete_ColorMap(ColorMap *cmap); - -FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -void delete_FrameBuffer(FrameBuffer *frame); -void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); - -/* And some useful constants */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - - - - - diff --git a/Examples/chicken/zlib/Makefile b/Examples/chicken/zlib/Makefile deleted file mode 100644 index 720701444..000000000 --- a/Examples/chicken/zlib/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -INTERFACE = example.i -SRCS = -CXXSRCS = -TARGET = zlib -INCLUDE = -SWIGOPT = -I/usr/include -CFLAGS = -VARIANT = -LIBS = -lz -VARIANT = _direct - -all:: $(TARGET) - -$(TARGET): $(INTERFACE) $(SRCS) - $(MAKE) -f $(TOP)/Makefile \ - SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \ - INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \ - SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT) - -clean:: - $(MAKE) -f $(TOP)/Makefile chicken_clean - rm -f example.scm - rm -f $(TARGET) - -check:: - csi test-zlib.scm diff --git a/Examples/chicken/zlib/README.html b/Examples/chicken/zlib/README.html deleted file mode 100644 index b082a310c..000000000 --- a/Examples/chicken/zlib/README.html +++ /dev/null @@ -1,1666 +0,0 @@ - - - - zlib - Chicken - SWIG example - - -

      zlib - Chicken - SWIG

      - -

      Table of Contents

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

      Building the example

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

      zlib.h

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

      How the zlib wrapper was developed

      - -

      Attempt #1

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

      Attempt #2

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

      Attempt #3

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

      Attempt #4

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

      Attempt #5

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

      Attempt #6

      - - When we have to finesse strings, we must use typemaps. As well, - we define some functions to save and restore the - next_out element. We try again. - -
      -
      -/* File : example.i */
      -%module example
      -%{
      -/* Put headers and other declarations here */
      -#include "zlib.h"
      -%}
      -
      -%include typemaps.i
      -
      -%rename(VERSION) ZLIB_VERSION;
      -%rename(z_error) zError;
      -%apply char * { Bytef * };
      -	
      -/* Allow the sourceLen to be automatically filled in from the length
      -   of the 'source' string */
      -%typemap(in) (const Bytef *source, uLong sourceLen)
      -%{  if (!C_swig_is_string ($input)) {
      -    swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string");
      -  }
      -  $2 = (uLong) C_header_size ($input);
      -  $1 = C_c_string ($input);
      -%}
      -
      -/* Allocate space the size of which is determined by the Scheme
      -   integer argument, and make a temporary integer so we can set
      -   destLen. */
      -%typemap(in) (Bytef *dest, uLongf *destLen) (uLong len)
      -%{  if (!C_swig_is_fixnum ($input)) {
      -    swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a integer");
      -  }
      -  len = (uLong) C_unfix ($input);
      -  $2 = &len;
      -  $1 = (char *) malloc (*$2);
      -%}
      -
      -/* Return the mutated string as a new object. */
      -%typemap(argout) (Bytef *dest, uLongf *destLen) 
      -(C_word *scmstr) 
      -%{  scmstr = C_alloc (C_SIZEOF_STRING (*$2));
      -  SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1));
      -  free ($1);
      -%}
      -	
      -%include "zconf.h"
      -%include "zlib.h"
      -	
      -/* Ignore destLen as an input argument, and make a temporary integer so
      -   we can set destLen. */
      -%typemap(in, numinputs=0) uLongf *destLen (uLong len)
      -"$1 = &len;";
      -
      -/* Return a sized string as a new object. */
      -%typemap(argout)
      -(void *outstr, uLongf *destLen) (C_word *scmstr) 
      -%{  scmstr = C_alloc (C_SIZEOF_STRING (*$2));
      -  SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1));
      -%}
      -	
      -%inline %{
      -/* %inline blocks are seen by SWIG and are inserted into the header
      -   portion of example_wrap.c, so that they are also seen by the C
      -   compiler. */
      -int deflate_init(z_streamp strm, int level) {
      -  return deflateInit(strm,level); /* call macro */
      -}
      -int inflate_init(z_streamp strm) {
      -  return inflateInit(strm); /* call macro */
      -}
      -void* z_stream_save_next_out(z_streamp strm) {
      -  return (void*) strm->next_out;
      -}
      -void z_stream_get_next_chunk(z_streamp strm, void *outstr, uLongf *destLen) {
      -  *destLen = strm->next_out - (Bytef*)outstr;
      -}
      -%}
      -      
      -
      - - And that's it. Try building the entire example from the - Makefile. Run ./zlib test-zlib.scm to test it out. - - - diff --git a/Examples/chicken/zlib/example.i b/Examples/chicken/zlib/example.i deleted file mode 100644 index dd962ad56..000000000 --- a/Examples/chicken/zlib/example.i +++ /dev/null @@ -1,76 +0,0 @@ -/* File : example.i */ -%module example -%{ -/* Put headers and other declarations here */ -#include "zlib.h" -%} - -%include typemaps.i - -%rename(VERSION) ZLIB_VERSION; -%rename(z_error) zError; -%apply char * { Bytef * }; - -/* Allow the sourceLen to be automatically filled in from the length - of the 'source' string */ -%typemap(in) (const Bytef *source, uLong sourceLen) -%{ if (!C_swig_is_string ($input)) { - swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string"); - } - $2 = (uLong) C_header_size ($input); - $1 = C_c_string ($input); -%} - -/* Allocate space the size of which is determined by the Scheme - integer argument, and make a temporary integer so we can set - destLen. */ -%typemap(in) (Bytef *dest, uLongf *destLen) (uLong len) -%{ if (!C_swig_is_fixnum ($input)) { - swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a integer"); - } - len = (uLong) C_unfix ($input); - $2 = &len; - $1 = (char *) malloc (*$2); -%} - -/* Return the mutated string as a new object. */ -%typemap(argout) (Bytef *dest, uLongf *destLen) -(C_word *scmstr) -%{ scmstr = C_alloc (C_SIZEOF_STRING (*$2)); - SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1)); - free ($1); -%} - -%include "zconf.h" -%include "zlib.h" - -/* Ignore destLen as an input argument, and make a temporary integer so - we can set destLen. */ -%typemap(numinputs=0) uLongf *destLen (uLong len) -"$1 = &len;"; - -/* Return a sized string as a new object. */ -%typemap(argout) -(void *outstr, uLongf *destLen) (C_word *scmstr) -%{ scmstr = C_alloc (C_SIZEOF_STRING (*$2)); - SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1)); -%} - -%inline %{ -/* %inline blocks are seen by SWIG and are inserted into the header - portion of example_wrap.c, so that they are also seen by the C - compiler. */ -int deflate_init(z_streamp strm, int level) { - return deflateInit(strm,level); /* call macro */ -} -int inflate_init(z_streamp strm) { - return inflateInit(strm); /* call macro */ -} -void* z_stream_save_next_out(z_streamp strm) { - return (void*) strm->next_out; -} -void z_stream_get_next_chunk(z_streamp strm, void *outstr, uLongf *destLen) { - *destLen = strm->next_out - (Bytef*)outstr; -} -%} - diff --git a/Examples/chicken/zlib/test-zlib.scm b/Examples/chicken/zlib/test-zlib.scm deleted file mode 100644 index a13d801b8..000000000 --- a/Examples/chicken/zlib/test-zlib.scm +++ /dev/null @@ -1,41 +0,0 @@ -(load-library 'example "./zlib.so") - -;; Init zstream -(define s (new-z-stream)) -(z-stream-zalloc-set s #f) -(z-stream-zfree-set s #f) -(z-stream-opaque-set s #f) -(deflate-init s (Z-DEFAULT-COMPRESSION)) - -;; Deflate something small so we don't need to loop/stream data -(define in "some pony et jumping et jack et flash et had a jack pony") -(define out (make-string 1000)) -(printf "to be compressed: ~A~%to be compressed bytes: ~A~%~%" in (string-length in)) -(z-stream-next-in-set s in) -(z-stream-avail-in-set s (string-length in)) -(z-stream-next-out-set s out) -(z-stream-avail-out-set s (string-length out)) -(let* - ((saved-out (z-stream-save-next-out s)) - (ret (deflate s (Z-FINISH)))) - (cond - ((= ret (Z-STREAM-END)) - (printf "deflated properly!~%compressed bytes: ~A~%compressed stream: ~A~%" - (z-stream-total-out-get s) (z-stream-get-next-chunk s saved-out))) - ((= ret (Z-OK)) - (display "only partial deflation ... not enough output space\n")) - (else - (printf "deflate error(~D): ~A ~%" ret (z-stream-msg-get s))))) - -;; Use simple compress routine, and set max output size to 100 -(newline) -(call-with-values (lambda () (compress 100 in)) - (lambda (ret compressed) - (cond - ((= ret (Z-OK)) - (printf "compressed properly!~%compressed bytes: ~A~%compressed stream: ~A~%" - (string-length compressed) compressed)) - (else - (printf "compress error(~D): ~A ~%" ret (z-error ret)))))) - -(exit 0) diff --git a/Examples/guile/check.list b/Examples/guile/check.list index d35b2d693..7ccd0730a 100644 --- a/Examples/guile/check.list +++ b/Examples/guile/check.list @@ -1,6 +1,5 @@ # see top-level Makefile.in constants -matrix simple port multimap diff --git a/Examples/lua/lua.c b/Examples/lua/lua.c index e06e2c5fc..8cffaa503 100644 --- a/Examples/lua/lua.c +++ b/Examples/lua/lua.c @@ -1,5 +1,4 @@ /* -** $Id$ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ diff --git a/Examples/test-suite/csharp/li_std_map_runme.cs b/Examples/test-suite/csharp/li_std_map_runme.cs index 2cdd5f5bc..b0a5a78e4 100644 --- a/Examples/test-suite/csharp/li_std_map_runme.cs +++ b/Examples/test-suite/csharp/li_std_map_runme.cs @@ -1,12 +1,7 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * li_std_map_runme.cs * * SWIG C# tester for std_map.i - * Implementation by Yuval Baror (http://yuval.bar-or.org) - * * 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. diff --git a/Examples/test-suite/li_std_queue.i b/Examples/test-suite/li_std_queue.i index 2d322b4d9..6bf71afca 100644 --- a/Examples/test-suite/li_std_queue.i +++ b/Examples/test-suite/li_std_queue.i @@ -1,13 +1,4 @@ -/** - * @file std_queue.i - * @author gga - * @date Sun May 6 01:52:44 2007 - * - * @brief test of std::queue - * - * - */ - +// test of std::queue %module li_std_queue %include std_queue.i diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i index 8c335b24c..2dcc2f17c 100644 --- a/Examples/test-suite/li_std_set.i +++ b/Examples/test-suite/li_std_set.i @@ -1,18 +1,12 @@ -/** - * @file li_std_set.i - * @author gga - * @date Tue May 1 02:52:47 2007 - * - * @brief 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. +/* + * 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 - * - * + * For example: + * swig::LANGUAGE_OBJ is GC_VALUE in Ruby + * swig::LANGUAGE_OBJ is SwigPtr_PyObject in python */ %module li_std_set diff --git a/Examples/test-suite/li_std_stack.i b/Examples/test-suite/li_std_stack.i index d29254089..19b45d46f 100644 --- a/Examples/test-suite/li_std_stack.i +++ b/Examples/test-suite/li_std_stack.i @@ -1,13 +1,4 @@ -/** - * @file std_stack.i - * @author gga - * @date Sun May 6 01:52:44 2007 - * - * @brief test of std::stack - * - * - */ - +// test of std::stack %module li_std_stack %include std_stack.i diff --git a/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb b/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb index 825f3c593..e79cb46a8 100755 --- a/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb +++ b/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb @@ -3,9 +3,6 @@ # This is a simple speed benchmark suite for std containers, # to verify their O(n) performance. # It is not part of the standard tests. -# -# License:: SWIG -# require 'benchmark' diff --git a/Examples/test-suite/ruby_li_std_speed.i b/Examples/test-suite/ruby_li_std_speed.i index 3c8e60643..bfb0b2776 100644 --- a/Examples/test-suite/ruby_li_std_speed.i +++ b/Examples/test-suite/ruby_li_std_speed.i @@ -1,13 +1,4 @@ -/** - * @file ruby_li_std_speed.i - * @author gga - * @date Fri May 18 18:03:15 2007 - * - * @brief A speed test of the ruby stl - * - * - */ - +// A speed test of the ruby stl %module ruby_li_std_speed %include diff --git a/Examples/xml/example_gif.i b/Examples/xml/example_gif.i deleted file mode 100644 index f0fb3b183..000000000 --- a/Examples/xml/example_gif.i +++ /dev/null @@ -1,329 +0,0 @@ -/* ----------------------------------------------------------------------------- - * gifplot.h - * - * Main header file for the GIFPlot library. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * Copyright (C) 1995-1996 - * - * See the file LICENSE for information on usage and redistribution. - * ----------------------------------------------------------------------------- */ - -#include -#include -#include -#include -#include -#include - -#ifndef GIFPLOT_H - -/* Pixel is 8-bits */ - -typedef unsigned char Pixel; -typedef float Zvalue; - -/* ------------------------------------------------------------------------ - ColorMap - - Definition and methods for colormaps - ------------------------------------------------------------------------ */ - -typedef struct ColorMap { - unsigned char *cmap; - char *name; -} ColorMap; - -extern ColorMap *new_ColorMap(char *filename); -extern void delete_ColorMap(ColorMap *c); -extern void ColorMap_default(ColorMap *c); -extern void ColorMap_assign(ColorMap *c, int index, int r, int g, int b); -extern int ColorMap_getitem(ColorMap *c, int index); -extern void ColorMap_setitem(ColorMap *c, int index, int value); -extern int ColorMap_write(ColorMap *c, char *filename); - -/* Some default colors */ - -#define BLACK 0 -#define WHITE 1 -#define RED 2 -#define GREEN 3 -#define BLUE 4 -#define YELLOW 5 -#define CYAN 6 -#define MAGENTA 7 - -/*------------------------------------------------------------------------- - FrameBuffer - - This structure defines a simple 8 bit framebuffer. - ------------------------------------------------------------------------- */ - -typedef struct FrameBuffer { - Pixel **pixels; - Zvalue **zbuffer; - unsigned int height; - unsigned int width; - int xmin; /* These are used for clipping */ - int ymin; - int xmax; - int ymax; -} FrameBuffer; - -#define ZMIN 1e+36 - -/* FrameBuffer Methods */ - -extern FrameBuffer *new_FrameBuffer(unsigned int width, unsigned int height); -extern void delete_FrameBuffer(FrameBuffer *frame); -extern int FrameBuffer_resize(FrameBuffer *frame, int width, int height); -extern void FrameBuffer_clear(FrameBuffer *frame, Pixel color); -extern void FrameBuffer_plot(FrameBuffer *frame, int x, int y, Pixel color); -extern void FrameBuffer_horizontal(FrameBuffer *frame, int xmin, int xmax, int y, Pixel color); -extern void FrameBuffer_horizontalinterp(FrameBuffer *f, int xmin, int xmax, int y, Pixel c1, Pixel c2); -extern void FrameBuffer_vertical(FrameBuffer *frame, int ymin, int ymax, int x, Pixel color); -extern void FrameBuffer_box(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -extern void FrameBuffer_solidbox(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -extern void FrameBuffer_interpbox(FrameBuffer *f, int x1, int y1, int x2, int y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); -extern void FrameBuffer_circle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -extern void FrameBuffer_solidcircle(FrameBuffer *frame, int x1, int y1, int radius, Pixel color); -extern void FrameBuffer_line(FrameBuffer *frame, int x1, int y1, int x2, int y2, Pixel color); -extern void FrameBuffer_setclip(FrameBuffer *frame, int xmin, int ymin, int xmax, int ymax); -extern void FrameBuffer_noclip(FrameBuffer *frame); -extern int FrameBuffer_makeGIF(FrameBuffer *frame, ColorMap *cmap, void *buffer, unsigned int maxsize); -extern int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename); -extern void FrameBuffer_zresize(FrameBuffer *f, int width, int height); -extern void FrameBuffer_zclear(FrameBuffer *f); -extern void FrameBuffer_solidtriangle(FrameBuffer *f, int x1, int y1, int x2, int y2, int x3, int y3, Pixel c); -extern void FrameBuffer_interptriangle(FrameBuffer *f, int tx1, int ty1, Pixel c1, - int tx2, int ty2, Pixel c2, int tx3, int ty3, Pixel c3); - -#define HORIZONTAL 1 -#define VERTICAL 2 - -extern void FrameBuffer_drawchar(FrameBuffer *frame, int x, int y, int fgcolor, int bgcolor, char chr, int orientation); -extern void FrameBuffer_drawstring(FrameBuffer *f, int x, int y, int fgcolor, int bgcolor, char *text, int orientation); - -/* ------------------------------------------------------------------------ - PixMap - - The equivalent of "bit-maps". - ------------------------------------------------------------------------ */ - -typedef struct PixMap { - int width; - int height; - int centerx; - int centery; - int *map; -} PixMap; - -/* PIXMAP methods */ - -extern PixMap *new_PixMap(int width, int height, int centerx, int centery); -extern void delete_PixMap(PixMap *pm); -extern void PixMap_set(PixMap *pm, int x, int y, int pix); -extern void FrameBuffer_drawpixmap(FrameBuffer *f, PixMap *pm, int x, int y, int fgcolor, int bgcolor); - -#define TRANSPARENT 0 -#define FOREGROUND 1 -#define BACKGROUND 2 - -/* ------------------------------------------------------------------------ - Plot2D - - Definition and methods for 2D plots. - ------------------------------------------------------------------------ */ - -typedef struct Plot2D { - FrameBuffer *frame; /* what frame buffer are we using */ - int view_xmin; /* Minimum coordinates of view region */ - int view_ymin; - int view_xmax; /* Maximum coordinates of view region */ - int view_ymax; - double xmin; /* Minimum coordinates of plot region */ - double ymin; - double xmax; /* Maximum coordinates of plot region */ - double ymax; - int xscale; /* Type of scaling (LINEAR, LOG, etc..) */ - int yscale; - double dx; /* Private scaling parameters */ - double dy; -} Plot2D; - -/* 2D Plot methods */ - -extern Plot2D *new_Plot2D(FrameBuffer *frame,double xmin,double ymin, double xmax, double ymax); -extern void delete_Plot2D(Plot2D *p2); -extern Plot2D *Plot2D_copy(Plot2D *p2); -extern void Plot2D_clear(Plot2D *p2, Pixel c); -extern void Plot2D_setview(Plot2D *p2, int vxmin, int vymin, int vxmax, int vymax); -extern void Plot2D_setrange(Plot2D *p2, double xmin, double ymin, double xmax, double ymax); -extern void Plot2D_setscale(Plot2D *p2, int xscale, int yscale); -extern void Plot2D_plot(Plot2D *p2, double x, double y, Pixel color); -extern void Plot2D_box(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color); -extern void Plot2D_solidbox(Plot2D *p2, double x1, double y1,double x2, double y2, Pixel color); -extern void Plot2D_interpbox(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel c1, Pixel c2, Pixel c3, Pixel c4); -extern void Plot2D_circle(Plot2D *p2, double x, double y, double radius, Pixel color); -extern void Plot2D_solidcircle(Plot2D *p2, double x, double y, double radius, Pixel color); -extern void Plot2D_line(Plot2D *p2, double x1, double y1, double x2, double y2, Pixel color); -extern void Plot2D_start(Plot2D *p2); -extern void Plot2D_drawpixmap(Plot2D *p2, PixMap *pm, double x, double y, Pixel color, Pixel bgcolor); -extern void Plot2D_xaxis(Plot2D *p2, double x, double y, double xtick, int ticklength, Pixel c); -extern void Plot2D_yaxis(Plot2D *p2, double x, double y, double ytick, int ticklength, Pixel c); -extern void Plot2D_triangle(Plot2D *p2, double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); -extern void Plot2D_solidtriangle(Plot2D *p2, double x1, double y1, double x2, double y2, double x3, double y3, Pixel c); -extern void Plot2D_interptriangle(Plot2D *p2, double x1, double y1, Pixel c1, - double x2, double y2, Pixel c2, - double x3, double y3, Pixel c3); - -#define LINEAR 10 -#define LOG 11 - -/* ----------------------------------------------------------------------- - Matrix - - Operations on 4x4 transformation matrices and vectors. - Matrices are represented as a double array of 16 elements - ----------------------------------------------------------------------- */ - -typedef double *Matrix; -typedef struct GL_Vector { - double x; - double y; - double z; - double w; -} GL_Vector; - -extern Matrix new_Matrix(); -extern void delete_Matrix(Matrix a); -extern Matrix Matrix_copy(Matrix a); -extern void Matrix_multiply(Matrix a, Matrix b, Matrix c); -extern void Matrix_identity(Matrix a); -extern void Matrix_zero(Matrix a); -extern void Matrix_transpose(Matrix a, Matrix result); -extern void Matrix_invert(Matrix a, Matrix inva); -extern void Matrix_transform(Matrix a, GL_Vector *r, GL_Vector *t); -extern void Matrix_transform4(Matrix a, double rx, double ry, double rz, - double rw, GL_Vector *t); - -extern void Matrix_print(Matrix a); -extern void Matrix_translate(Matrix a, double tx, double ty, double tz); -extern void Matrix_rotatex(Matrix a, double deg); -extern void Matrix_rotatey(Matrix a, double deg); -extern void Matrix_rotatez(Matrix a, double deg); - -/* ----------------------------------------------------------------------- - Plot3D - - Data Structure for 3-D plots - ------------------------------------------------------------------------ */ - -typedef struct Plot3D { - FrameBuffer *frame; /* Frame buffer being used */ - int view_xmin; /* Viewing region */ - int view_ymin; - int view_xmax; - int view_ymax; - double xmin; /* Bounding box */ - double ymin; - double zmin; - double xmax; - double ymax; - double zmax; - double xcenter; /* Center point */ - double ycenter; - double zcenter; - double fovy; /* Field of view */ - double aspect; /* Aspect ratio */ - double znear; /* near "clipping" plane */ - double zfar; /* far "clipping" plane */ - Matrix center_mat; /* Matrix used for centering the model */ - Matrix model_mat; /* Model rotation matrix */ - Matrix view_mat; /* Viewing matrix */ - Matrix fullmodel_mat; /* Full model matrix. Used by sphere plot */ - Matrix trans_mat; /* Total transformation matrix */ - double lookatz; /* Where is the z-lookat point */ - double xshift; /* Used for translation and stuff */ - double yshift; - double zoom; - int width; - int height; - int pers_mode; /* Perspective mode (private) */ - double ortho_left,ortho_right,ortho_bottom,ortho_top; -} Plot3D; - -extern Plot3D *new_Plot3D(FrameBuffer *frame, double xmin, double ymin, double zmin, - double xmax, double ymax, double zmax); -extern void delete_Plot3D(Plot3D *p3); -extern Plot3D *Plot3D_copy(Plot3D *p3); -extern void Plot3D_clear(Plot3D *p3, Pixel Color); -extern void Plot3D_perspective(Plot3D *p3, double fovy, double znear, double zfar); -extern void Plot3D_ortho(Plot3D *p3, double left, double right, double top, double bottom); -extern void Plot3D_lookat(Plot3D *p3, double z); -extern void Plot3D_autoperspective(Plot3D *p3, double fovy); -extern void Plot3D_autoortho(Plot3D *p3); -extern void Plot3D_rotx(Plot3D *p3, double deg); -extern void Plot3D_roty(Plot3D *p3, double deg); -extern void Plot3D_rotz(Plot3D *p3, double deg); -extern void Plot3D_rotl(Plot3D *p3, double deg); -extern void Plot3D_rotr(Plot3D *p3, double deg); -extern void Plot3D_rotd(Plot3D *p3, double deg); -extern void Plot3D_rotu(Plot3D *p3, double deg); -extern void Plot3D_rotc(Plot3D *p3, double deg); -extern void Plot3D_zoom(Plot3D *p3, double percent); -extern void Plot3D_left(Plot3D *p3, double percent); -extern void Plot3D_right(Plot3D *p3, double percent); -extern void Plot3D_down(Plot3D *p3, double percent); -extern void Plot3D_up(Plot3D *p3, double percent); -extern void Plot3D_center(Plot3D *p3, double cx, double cy); - -extern void Plot3D_plot(Plot3D *p3, double x, double y, double z, Pixel Color); - -extern void Plot3D_setview(Plot3D *p3, int vxmin, int vymin, int vxmax, int vymax); -extern void Plot3D_start(Plot3D *p3); -extern void Plot3D_line(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, Pixel color); -extern void Plot3D_triangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color); -extern void Plot3D_solidtriangle(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, Pixel color); - -extern void Plot3D_interptriangle(Plot3D *p3, - double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3); - -extern void Plot3D_quad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color); - -extern void Plot3D_solidquad(Plot3D *p3, double x1, double y1, double z1, - double x2, double y2, double z2, - double x3, double y3, double z3, - double x4, double y4, double z4, - Pixel color); - -extern void Plot3D_interpquad(Plot3D *p3, double x1, double y1, double z1, Pixel c1, - double x2, double y2, double z2, Pixel c2, - double x3, double y3, double z3, Pixel c3, - double x4, double y4, double z4, Pixel c4); - - -extern void Plot3D_solidsphere(Plot3D *p3, double x, double y, double z, double radius,Pixel c); - -extern void Plot3D_outlinesphere(Plot3D *p3, double x, double y, double z, double radius,Pixel c, Pixel bc); - -extern PixMap PixMap_SQUARE; -extern PixMap PixMap_TRIANGLE; -extern PixMap PixMap_CROSS; - -#endif -#define GIFPLOT_H - - - diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg index 4479f6ac2..266303113 100644 --- a/Lib/allegrocl/allegrocl.swg +++ b/Lib/allegrocl/allegrocl.swg @@ -289,8 +289,6 @@ $body)" #endif %insert("lisphead") %{ -;; $Id$ - (eval-when (:compile-toplevel :load-toplevel :execute) ;; avoid compiling ef-templates at runtime diff --git a/Lib/allegrocl/longlongs.i b/Lib/allegrocl/longlongs.i index b887a8a0a..4aa54660b 100644 --- a/Lib/allegrocl/longlongs.i +++ b/Lib/allegrocl/longlongs.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * longlongs.i * * Typemap addition for support of 'long long' type and 'unsigned long long diff --git a/Lib/allegrocl/std_list.i b/Lib/allegrocl/std_list.i index c8ab45649..4e260897f 100644 --- a/Lib/allegrocl/std_list.i +++ b/Lib/allegrocl/std_list.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_list.i * * SWIG typemaps for std::list types diff --git a/Lib/allegrocl/std_string.i b/Lib/allegrocl/std_string.i index 4da0148fe..becc322e9 100644 --- a/Lib/allegrocl/std_string.i +++ b/Lib/allegrocl/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_string.i * * SWIG typemaps for std::string diff --git a/Lib/attribute.i b/Lib/attribute.i index 45c3c5b64..0cc3ff1a3 100644 --- a/Lib/attribute.i +++ b/Lib/attribute.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * attribute.i * * SWIG library file for implementing attributes. diff --git a/Lib/carrays.i b/Lib/carrays.i index 738b4577a..5fc78877c 100644 --- a/Lib/carrays.i +++ b/Lib/carrays.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * carrays.i * * SWIG library file containing macros that can be used to manipulate simple diff --git a/Lib/cdata.i b/Lib/cdata.i index b970b1d5d..1abaf357b 100644 --- a/Lib/cdata.i +++ b/Lib/cdata.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * cdata.i * * SWIG library file containing macros for manipulating raw C data as strings. diff --git a/Lib/chicken/chicken.swg b/Lib/chicken/chicken.swg index a8d1b5a57..68f022570 100644 --- a/Lib/chicken/chicken.swg +++ b/Lib/chicken/chicken.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * chicken.swg * * CHICKEN configuration module. diff --git a/Lib/chicken/chickenrun.swg b/Lib/chicken/chickenrun.swg index 8703ea65a..f4e94d6f6 100644 --- a/Lib/chicken/chickenrun.swg +++ b/Lib/chicken/chickenrun.swg @@ -1,9 +1,5 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * chickenrun.swg - * * ----------------------------------------------------------------------------- */ #include diff --git a/Lib/chicken/multi-generic.scm b/Lib/chicken/multi-generic.scm index ae822f37b..9d2e31d34 100644 --- a/Lib/chicken/multi-generic.scm +++ b/Lib/chicken/multi-generic.scm @@ -21,7 +21,7 @@ ;; which functions are used when. ;; Comments, bugs, suggestions: send either to chicken-users@nongnu.org or to -;; Author: John Lenz , most code copied from TinyCLOS +;; Most code copied from TinyCLOS (define (make 'name "multi-generic" diff --git a/Lib/chicken/std_string.i b/Lib/chicken/std_string.i index 2955d0e2f..ce24cba32 100644 --- a/Lib/chicken/std_string.i +++ b/Lib/chicken/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_string.i * * SWIG typemaps for std::string diff --git a/Lib/chicken/typemaps.i b/Lib/chicken/typemaps.i index d79e20184..56cd18a5d 100644 --- a/Lib/chicken/typemaps.i +++ b/Lib/chicken/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.i * * Pointer handling diff --git a/Lib/clisp/clisp.swg b/Lib/clisp/clisp.swg index fb6cdbf2a..e1d330cb3 100644 --- a/Lib/clisp/clisp.swg +++ b/Lib/clisp/clisp.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * clisp.swg * ----------------------------------------------------------------------------- */ diff --git a/Lib/cmalloc.i b/Lib/cmalloc.i index 03a61351c..9f58bc03c 100644 --- a/Lib/cmalloc.i +++ b/Lib/cmalloc.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * cmalloc.i * * SWIG library file containing macros that can be used to create objects using diff --git a/Lib/constraints.i b/Lib/constraints.i index 2deb1168a..8bc7f9159 100644 --- a/Lib/constraints.i +++ b/Lib/constraints.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * constraints.i * * SWIG constraints library. diff --git a/Lib/cpointer.i b/Lib/cpointer.i index 1a6e51741..6b15a8417 100644 --- a/Lib/cpointer.i +++ b/Lib/cpointer.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * cpointer.i * * SWIG library file containing macros that can be used to manipulate simple diff --git a/Lib/csharp/arrays_csharp.i b/Lib/csharp/arrays_csharp.i index ea22da584..513330e4e 100644 --- a/Lib/csharp/arrays_csharp.i +++ b/Lib/csharp/arrays_csharp.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * arrays_csharp.i * * This file contains a two approaches to marshaling arrays. The first uses diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index fe459547c..204cf4b2f 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * csharp.swg * * C# typemaps diff --git a/Lib/csharp/csharphead.swg b/Lib/csharp/csharphead.swg index 927a54b3b..9b144d6a5 100644 --- a/Lib/csharp/csharphead.swg +++ b/Lib/csharp/csharphead.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * csharphead.swg * * Support code for exceptions if the SWIG_CSHARP_NO_EXCEPTION_HELPER is not defined diff --git a/Lib/csharp/director.swg b/Lib/csharp/director.swg index 8957ecf42..7768d8c02 100644 --- a/Lib/csharp/director.swg +++ b/Lib/csharp/director.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * director.swg * * This file contains support for director classes so that C# proxy diff --git a/Lib/csharp/enums.swg b/Lib/csharp/enums.swg index be2a6063b..6605da8c8 100644 --- a/Lib/csharp/enums.swg +++ b/Lib/csharp/enums.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * enums.swg * * Include this file in order for C/C++ enums to be wrapped by proper C# enums. diff --git a/Lib/csharp/enumsimple.swg b/Lib/csharp/enumsimple.swg index f50849892..2b1cb182b 100644 --- a/Lib/csharp/enumsimple.swg +++ b/Lib/csharp/enumsimple.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * enumsimple.swg * * This file provides backwards compatible enum wrapping. SWIG versions 1.3.21 diff --git a/Lib/csharp/enumtypesafe.swg b/Lib/csharp/enumtypesafe.swg index 8ba7838ef..a6bf64b9a 100644 --- a/Lib/csharp/enumtypesafe.swg +++ b/Lib/csharp/enumtypesafe.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * enumtypesafe.swg * * Include this file in order for C/C++ enums to be wrapped by the so called diff --git a/Lib/csharp/std_except.i b/Lib/csharp/std_except.i index c86e97a54..27eb84bc2 100644 --- a/Lib/csharp/std_except.i +++ b/Lib/csharp/std_except.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_except.i * * Typemaps used by the STL wrappers that throw exceptions. These typemaps are diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index f210a96ba..24efbe26f 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_map.i * * SWIG typemaps for std::map< K, T > diff --git a/Lib/csharp/std_pair.i b/Lib/csharp/std_pair.i index 78142ffa6..0712ad762 100644 --- a/Lib/csharp/std_pair.i +++ b/Lib/csharp/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/csharp/std_string.i b/Lib/csharp/std_string.i index d29692717..0d804518b 100644 --- a/Lib/csharp/std_string.i +++ b/Lib/csharp/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_string.i * * Typemaps for std::string and const std::string& diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index 64aad5807..57abe614d 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_vector.i * * SWIG typemaps for std::vector diff --git a/Lib/csharp/std_wstring.i b/Lib/csharp/std_wstring.i index 938070e4b..9142d36a5 100644 --- a/Lib/csharp/std_wstring.i +++ b/Lib/csharp/std_wstring.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_wstring.i * * Typemaps for std::wstring and const std::wstring& diff --git a/Lib/csharp/stl.i b/Lib/csharp/stl.i index 66b72e073..9d2e91eee 100644 --- a/Lib/csharp/stl.i +++ b/Lib/csharp/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/csharp/typemaps.i b/Lib/csharp/typemaps.i index 56cc6cb61..d50e5c46d 100644 --- a/Lib/csharp/typemaps.i +++ b/Lib/csharp/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.i * * Pointer and reference handling typemap library diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i index be87560c3..f02c09a53 100644 --- a/Lib/csharp/wchar.i +++ b/Lib/csharp/wchar.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * wchar.i * * Typemaps for the wchar_t type diff --git a/Lib/cstring.i b/Lib/cstring.i index 4ebdf6857..6829f7597 100644 --- a/Lib/cstring.i +++ b/Lib/cstring.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * cstring.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/cwstring.i b/Lib/cwstring.i index a6b08ae40..f0631d328 100644 --- a/Lib/cwstring.i +++ b/Lib/cwstring.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * cwstring.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/exception.i b/Lib/exception.i index a1a47554e..2bc86b458 100644 --- a/Lib/exception.i +++ b/Lib/exception.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * exception.i * * SWIG library file providing language independent exception handling diff --git a/Lib/gcj/cni.swg b/Lib/gcj/cni.swg index 247909a4a..4bd07df06 100644 --- a/Lib/gcj/cni.swg +++ b/Lib/gcj/cni.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * cni.swg * ----------------------------------------------------------------------------- */ diff --git a/Lib/guile/common.scm b/Lib/guile/common.scm index a51d3a71d..17c9ab580 100644 --- a/Lib/guile/common.scm +++ b/Lib/guile/common.scm @@ -3,12 +3,6 @@ ;;;* ;;;* This file contains generic SWIG GOOPS classes for generated ;;;* GOOPS file support -;;;* -;;;* Copyright (C) 2003 John Lenz (jelenz@wisc.edu) -;;;* Copyright (C) 2004 Matthias Koeppe (mkoeppe@mail.math.uni-magdeburg.de) -;;;* -;;;* This file may be freely redistributed without license or fee provided -;;;* this copyright message remains intact. ;;;************************************************************************ (define-module (Swig swigrun)) diff --git a/Lib/guile/cplusplus.i b/Lib/guile/cplusplus.i index cb4cf7434..0dfe71754 100644 --- a/Lib/guile/cplusplus.i +++ b/Lib/guile/cplusplus.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * cplusplus.i * * SWIG typemaps for C++ diff --git a/Lib/guile/guile.i b/Lib/guile/guile.i index 1bf28d6f3..ef270d74b 100644 --- a/Lib/guile/guile.i +++ b/Lib/guile/guile.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * guile.i * * SWIG Configuration File for Guile. diff --git a/Lib/guile/guile_gh.swg b/Lib/guile/guile_gh.swg index 6412a4c61..3b65af897 100644 --- a/Lib/guile/guile_gh.swg +++ b/Lib/guile/guile_gh.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * guile_gh.swg * * This SWIG interface file is processed if the Guile module is run diff --git a/Lib/guile/guile_gh_run.swg b/Lib/guile/guile_gh_run.swg index 5b1fca0aa..0eba1f97e 100644 --- a/Lib/guile/guile_gh_run.swg +++ b/Lib/guile/guile_gh_run.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * guile_gh_run.swg * * Guile GH runtime file diff --git a/Lib/guile/guile_scm.swg b/Lib/guile/guile_scm.swg index caded728d..d12401451 100644 --- a/Lib/guile/guile_scm.swg +++ b/Lib/guile/guile_scm.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * guile_scm.swg * * This SWIG interface file is processed if the Guile module is run diff --git a/Lib/guile/guile_scm_run.swg b/Lib/guile/guile_scm_run.swg index 5da8558fc..91b74095d 100644 --- a/Lib/guile/guile_scm_run.swg +++ b/Lib/guile/guile_scm_run.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * guile_scm_run.swg * ----------------------------------------------------------------------------- */ diff --git a/Lib/guile/guilemain.i b/Lib/guile/guilemain.i index 6f4e4d94d..925b81fee 100644 --- a/Lib/guile/guilemain.i +++ b/Lib/guile/guilemain.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * guilemain.i * * The main functions for a user augmented guile diff --git a/Lib/guile/interpreter.i b/Lib/guile/interpreter.i index 7e8f0777a..524e0694a 100644 --- a/Lib/guile/interpreter.i +++ b/Lib/guile/interpreter.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * interpreter.i * * SWIG file for a simple Guile interpreter diff --git a/Lib/guile/list-vector.i b/Lib/guile/list-vector.i index d98cae59a..c2cd1aea2 100644 --- a/Lib/guile/list-vector.i +++ b/Lib/guile/list-vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * list_vector.i * * Guile typemaps for converting between arrays and Scheme lists or vectors diff --git a/Lib/guile/pointer-in-out.i b/Lib/guile/pointer-in-out.i index bc6438759..d8a631ca9 100644 --- a/Lib/guile/pointer-in-out.i +++ b/Lib/guile/pointer-in-out.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * pointer-in-out.i * * Guile typemaps for passing pointers indirectly diff --git a/Lib/guile/ports.i b/Lib/guile/ports.i index 0d0e142e1..5940b4d3b 100644 --- a/Lib/guile/ports.i +++ b/Lib/guile/ports.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * ports.i * * Guile typemaps for handling ports diff --git a/Lib/guile/std_common.i b/Lib/guile/std_common.i index ace5d65a8..a46c42c69 100644 --- a/Lib/guile/std_common.i +++ b/Lib/guile/std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_common.i * * SWIG typemaps for STL - common utilities diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i index cc53e1560..19c863096 100644 --- a/Lib/guile/std_map.i +++ b/Lib/guile/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/guile/std_pair.i b/Lib/guile/std_pair.i index f8c2ea688..35f0cfad5 100644 --- a/Lib/guile/std_pair.i +++ b/Lib/guile/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/guile/std_string.i b/Lib/guile/std_string.i index f80a65ca5..c10806e98 100644 --- a/Lib/guile/std_string.i +++ b/Lib/guile/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_string.i * * SWIG typemaps for std::string diff --git a/Lib/guile/std_vector.i b/Lib/guile/std_vector.i index 145db945b..6801daee8 100644 --- a/Lib/guile/std_vector.i +++ b/Lib/guile/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_vector.i * * SWIG typemaps for std::vector diff --git a/Lib/guile/stl.i b/Lib/guile/stl.i index 66b72e073..9d2e91eee 100644 --- a/Lib/guile/stl.i +++ b/Lib/guile/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i index d9f972850..4f306f7f8 100644 --- a/Lib/guile/typemaps.i +++ b/Lib/guile/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.i * * Guile-specific typemaps diff --git a/Lib/inttypes.i b/Lib/inttypes.i index 0cc81948e..8450cb840 100644 --- a/Lib/inttypes.i +++ b/Lib/inttypes.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * inttypes.i * * SWIG library file for ISO C99 types: 7.8 Format conversion of integer types diff --git a/Lib/java/arrays_java.i b/Lib/java/arrays_java.i index 95510c3f9..ddaf7408c 100644 --- a/Lib/java/arrays_java.i +++ b/Lib/java/arrays_java.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * arrays_java.i * * These typemaps give more natural support for arrays. The typemaps are not efficient diff --git a/Lib/java/director.swg b/Lib/java/director.swg index fa588671d..07e5a1af1 100644 --- a/Lib/java/director.swg +++ b/Lib/java/director.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * director.swg * * This file contains support for director classes that proxy diff --git a/Lib/java/enums.swg b/Lib/java/enums.swg index 1a8f89b3a..edb67c417 100644 --- a/Lib/java/enums.swg +++ b/Lib/java/enums.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * enums.swg * * Include this file in order for C/C++ enums to be wrapped by proper Java enums. diff --git a/Lib/java/enumsimple.swg b/Lib/java/enumsimple.swg index f45774d0c..e08401869 100644 --- a/Lib/java/enumsimple.swg +++ b/Lib/java/enumsimple.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * enumsimple.swg * * This file provides backwards compatible enum wrapping. SWIG versions 1.3.21 diff --git a/Lib/java/enumtypesafe.swg b/Lib/java/enumtypesafe.swg index a49a9d134..d6c6e5190 100644 --- a/Lib/java/enumtypesafe.swg +++ b/Lib/java/enumtypesafe.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * enumtypesafe.swg * * Include this file in order for C/C++ enums to be wrapped by the so called diff --git a/Lib/java/enumtypeunsafe.swg b/Lib/java/enumtypeunsafe.swg index bda055113..d9a7c4d29 100644 --- a/Lib/java/enumtypeunsafe.swg +++ b/Lib/java/enumtypeunsafe.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * enumtypeunsafe.swg * * Include this file in order for C/C++ enums to be wrapped by integers values. diff --git a/Lib/java/java.swg b/Lib/java/java.swg index bd2357a86..6173502ca 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * java.swg * * Java typemaps diff --git a/Lib/java/javahead.swg b/Lib/java/javahead.swg index 7626bf50d..685bba198 100644 --- a/Lib/java/javahead.swg +++ b/Lib/java/javahead.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * javahead.swg * * Java support code diff --git a/Lib/java/std_except.i b/Lib/java/std_except.i index 15be1deb8..9e23d50e6 100644 --- a/Lib/java/std_except.i +++ b/Lib/java/std_except.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_except.i * * Typemaps used by the STL wrappers that throw exceptions. diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index 00967d3f9..a7020532c 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/java/std_pair.i b/Lib/java/std_pair.i index dc0604dc5..fe45ee676 100644 --- a/Lib/java/std_pair.i +++ b/Lib/java/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/java/std_string.i b/Lib/java/std_string.i index 789e17a65..f0d837696 100644 --- a/Lib/java/std_string.i +++ b/Lib/java/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_string.i * * Typemaps for std::string and const std::string& diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 29439606b..3f29b19c7 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_vector.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/java/std_wstring.i b/Lib/java/std_wstring.i index 989176500..12d8fc14f 100644 --- a/Lib/java/std_wstring.i +++ b/Lib/java/std_wstring.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_wstring.i * * Typemaps for std::wstring and const std::wstring& diff --git a/Lib/java/stl.i b/Lib/java/stl.i index b8d7a654c..04f86014f 100644 --- a/Lib/java/stl.i +++ b/Lib/java/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * stl.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/java/typemaps.i b/Lib/java/typemaps.i index 59f7af99a..74ed99374 100644 --- a/Lib/java/typemaps.i +++ b/Lib/java/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.i * * Pointer and reference handling typemap library diff --git a/Lib/java/various.i b/Lib/java/various.i index 733b8fa79..7c396de3e 100644 --- a/Lib/java/various.i +++ b/Lib/java/various.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * various.i * * SWIG Typemap library for Java. diff --git a/Lib/lua/_std_common.i b/Lib/lua/_std_common.i index 33cc513c3..e552d0c8f 100644 --- a/Lib/lua/_std_common.i +++ b/Lib/lua/_std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * _std_common.i * * std::helpers for LUA diff --git a/Lib/lua/lua.swg b/Lib/lua/lua.swg index b6d888670..c3f5cecc5 100644 --- a/Lib/lua/lua.swg +++ b/Lib/lua/lua.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * lua.swg * * SWIG Configuration File for Lua. diff --git a/Lib/lua/lua_fnptr.i b/Lib/lua/lua_fnptr.i index c7df6f5a3..7e9facdf3 100644 --- a/Lib/lua/lua_fnptr.i +++ b/Lib/lua/lua_fnptr.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * lua_fnptr.i * * SWIG Library file containing the main typemap code to support Lua modules. diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 9bb45d577..b4e979531 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * luarun.swg * * This file contains the runtime support for Lua modules diff --git a/Lib/lua/luaruntime.swg b/Lib/lua/luaruntime.swg index b82cd56d7..5823d4fcf 100644 --- a/Lib/lua/luaruntime.swg +++ b/Lib/lua/luaruntime.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * luaruntime.swg * * all the runtime code for . diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg index caa2a6ce1..401541267 100644 --- a/Lib/lua/luatypemaps.swg +++ b/Lib/lua/luatypemaps.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * luatypemaps.swg * * basic typemaps for Lua. diff --git a/Lib/lua/std_except.i b/Lib/lua/std_except.i index ce148ef63..9c736b9ef 100644 --- a/Lib/lua/std_except.i +++ b/Lib/lua/std_except.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * Typemaps used by the STL wrappers that throw exceptions. * These typemaps are used when methods are declared with an STL exception * specification, such as: diff --git a/Lib/lua/std_map.i b/Lib/lua/std_map.i index dd22443d5..84b0c74ff 100644 --- a/Lib/lua/std_map.i +++ b/Lib/lua/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/lua/std_pair.i b/Lib/lua/std_pair.i index 1b20f74e0..c76361554 100644 --- a/Lib/lua/std_pair.i +++ b/Lib/lua/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_pair.i * * std::pair typemaps for LUA diff --git a/Lib/lua/std_string.i b/Lib/lua/std_string.i index fa58f10bb..92f27d738 100644 --- a/Lib/lua/std_string.i +++ b/Lib/lua/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_string.i * * std::string typemaps for LUA diff --git a/Lib/lua/std_vector.i b/Lib/lua/std_vector.i index c6778087f..f248f0340 100644 --- a/Lib/lua/std_vector.i +++ b/Lib/lua/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_vector.i * * std::vector typemaps for LUA diff --git a/Lib/lua/stl.i b/Lib/lua/stl.i index b8d7a654c..04f86014f 100644 --- a/Lib/lua/stl.i +++ b/Lib/lua/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * stl.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i index fa0c0d0e5..084726e58 100644 --- a/Lib/lua/typemaps.i +++ b/Lib/lua/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.swg * * SWIG Library file containing the main typemap code to support Lua modules. diff --git a/Lib/lua/wchar.i b/Lib/lua/wchar.i index 5b206eb71..5021c1604 100644 --- a/Lib/lua/wchar.i +++ b/Lib/lua/wchar.i @@ -1,12 +1,8 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * wchar.i * * Typemaps for the wchar_t type * These are mapped to a Lua string and are passed around by value. - * * ----------------------------------------------------------------------------- */ // note: only support for pointer right now, not fixed length strings @@ -43,4 +39,4 @@ if ($1==0) {lua_pushfstring(L,"Error in converting to wchar (arg %d)",$input);go free($1); %} -%typemap(typecheck) wchar_t * = char *; \ No newline at end of file +%typemap(typecheck) wchar_t * = char *; diff --git a/Lib/math.i b/Lib/math.i index be931d71b..a37c92d19 100644 --- a/Lib/math.i +++ b/Lib/math.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * math.i * * SWIG library file for floating point operations. diff --git a/Lib/modula3/modula3.swg b/Lib/modula3/modula3.swg index 6a1b4d94d..599a12e5a 100644 --- a/Lib/modula3/modula3.swg +++ b/Lib/modula3/modula3.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * modula3.swg * * Modula3 typemaps diff --git a/Lib/modula3/modula3head.swg b/Lib/modula3/modula3head.swg index b2426be5f..af96a78d1 100644 --- a/Lib/modula3/modula3head.swg +++ b/Lib/modula3/modula3head.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * modula3head.swg * * Modula3 support code diff --git a/Lib/modula3/typemaps.i b/Lib/modula3/typemaps.i index 79ddfda0f..1d76ab5e0 100644 --- a/Lib/modula3/typemaps.i +++ b/Lib/modula3/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.i * * Pointer and reference handling typemap library diff --git a/Lib/mzscheme/mzrun.swg b/Lib/mzscheme/mzrun.swg index 3b05d2406..a5128da56 100644 --- a/Lib/mzscheme/mzrun.swg +++ b/Lib/mzscheme/mzrun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * mzrun.swg * ----------------------------------------------------------------------------- */ diff --git a/Lib/mzscheme/mzscheme.swg b/Lib/mzscheme/mzscheme.swg index ed4b2ec9d..9ae242845 100644 --- a/Lib/mzscheme/mzscheme.swg +++ b/Lib/mzscheme/mzscheme.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * mzscheme.swg * * SWIG Configuration File for MzScheme. diff --git a/Lib/mzscheme/std_common.i b/Lib/mzscheme/std_common.i index 8732f811c..1f1ae1ab7 100644 --- a/Lib/mzscheme/std_common.i +++ b/Lib/mzscheme/std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_common.i * * SWIG typemaps for STL - common utilities diff --git a/Lib/mzscheme/std_map.i b/Lib/mzscheme/std_map.i index aff720db6..b2c894509 100644 --- a/Lib/mzscheme/std_map.i +++ b/Lib/mzscheme/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/mzscheme/std_pair.i b/Lib/mzscheme/std_pair.i index 2ac331e71..d5a65470d 100644 --- a/Lib/mzscheme/std_pair.i +++ b/Lib/mzscheme/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/mzscheme/std_string.i b/Lib/mzscheme/std_string.i index c9a82efe4..b8b99d9ad 100644 --- a/Lib/mzscheme/std_string.i +++ b/Lib/mzscheme/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_string.i * * SWIG typemaps for std::string types diff --git a/Lib/mzscheme/std_vector.i b/Lib/mzscheme/std_vector.i index 90a52fc0a..22e1fa96b 100644 --- a/Lib/mzscheme/std_vector.i +++ b/Lib/mzscheme/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_vector.i * * SWIG typemaps for std::vector diff --git a/Lib/mzscheme/stl.i b/Lib/mzscheme/stl.i index 946e4b7f0..b19eae58b 100644 --- a/Lib/mzscheme/stl.i +++ b/Lib/mzscheme/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/mzscheme/typemaps.i b/Lib/mzscheme/typemaps.i index 334893242..b9f22440c 100644 --- a/Lib/mzscheme/typemaps.i +++ b/Lib/mzscheme/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/ocaml/cstring.i b/Lib/ocaml/cstring.i index e56258264..0d6aa4b69 100644 --- a/Lib/ocaml/cstring.i +++ b/Lib/ocaml/cstring.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * cstring.i * * This file provides typemaps and macros for dealing with various forms diff --git a/Lib/ocaml/director.swg b/Lib/ocaml/director.swg index 87333168f..a21f62102 100644 --- a/Lib/ocaml/director.swg +++ b/Lib/ocaml/director.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * director.swg * * This file contains support for director classes that proxy diff --git a/Lib/ocaml/ocaml.i b/Lib/ocaml/ocaml.i index a46e239d1..e099f7c10 100644 --- a/Lib/ocaml/ocaml.i +++ b/Lib/ocaml/ocaml.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * ocaml.i * * SWIG Configuration File for Ocaml diff --git a/Lib/ocaml/ocamldec.swg b/Lib/ocaml/ocamldec.swg index 3b5290fa1..8e452d3f9 100644 --- a/Lib/ocaml/ocamldec.swg +++ b/Lib/ocaml/ocamldec.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * ocamldec.swg * * Ocaml runtime code -- declarations diff --git a/Lib/ocaml/std_common.i b/Lib/ocaml/std_common.i index b2dff61d2..1c397050c 100644 --- a/Lib/ocaml/std_common.i +++ b/Lib/ocaml/std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_common.i * * SWIG typemaps for STL - common utilities diff --git a/Lib/ocaml/std_deque.i b/Lib/ocaml/std_deque.i index baadb4e53..5b38962bf 100644 --- a/Lib/ocaml/std_deque.i +++ b/Lib/ocaml/std_deque.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_deque.i * * Default std_deque wrapper diff --git a/Lib/ocaml/std_list.i b/Lib/ocaml/std_list.i index 0aea90767..06181cca8 100644 --- a/Lib/ocaml/std_list.i +++ b/Lib/ocaml/std_list.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_list.i * * SWIG typemaps for std::list types diff --git a/Lib/ocaml/std_map.i b/Lib/ocaml/std_map.i index f174f2872..f202e74ed 100644 --- a/Lib/ocaml/std_map.i +++ b/Lib/ocaml/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/ocaml/std_pair.i b/Lib/ocaml/std_pair.i index dc0604dc5..fe45ee676 100644 --- a/Lib/ocaml/std_pair.i +++ b/Lib/ocaml/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/ocaml/std_string.i b/Lib/ocaml/std_string.i index 7add3a070..e75e95304 100644 --- a/Lib/ocaml/std_string.i +++ b/Lib/ocaml/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_string.i * * SWIG typemaps for std::string diff --git a/Lib/ocaml/std_vector.i b/Lib/ocaml/std_vector.i index 91c335562..53d107447 100644 --- a/Lib/ocaml/std_vector.i +++ b/Lib/ocaml/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_vector.i * * SWIG typemaps for std::vector types diff --git a/Lib/ocaml/stl.i b/Lib/ocaml/stl.i index 66b72e073..9d2e91eee 100644 --- a/Lib/ocaml/stl.i +++ b/Lib/ocaml/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/ocaml/typecheck.i b/Lib/ocaml/typecheck.i index 51e66061b..4c3500690 100644 --- a/Lib/ocaml/typecheck.i +++ b/Lib/ocaml/typecheck.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typecheck.i * * Typechecking rules diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index 7f978bf7f..39544de94 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.i * * The Ocaml module handles all types uniformly via typemaps. Here diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg index afc3ed147..6613fcfff 100644 --- a/Lib/octave/octcontainer.swg +++ b/Lib/octave/octcontainer.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * octcontainer.swg * * Octave cell <-> C++ container wrapper diff --git a/Lib/octave/octiterators.swg b/Lib/octave/octiterators.swg index 926361e10..0e3fe7033 100644 --- a/Lib/octave/octiterators.swg +++ b/Lib/octave/octiterators.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * octiterators.swg * * Users can derive form the OctSwigIterator to implemet their diff --git a/Lib/perl5/perlmain.i b/Lib/perl5/perlmain.i index f224b9c75..18ecb7eb5 100644 --- a/Lib/perl5/perlmain.i +++ b/Lib/perl5/perlmain.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * perlmain.i * * Code to statically rebuild perl5. diff --git a/Lib/perl5/reference.i b/Lib/perl5/reference.i index 6f5eda518..fdc9c1320 100644 --- a/Lib/perl5/reference.i +++ b/Lib/perl5/reference.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * reference.i * * Accept Perl references as pointers diff --git a/Lib/perl5/std_common.i b/Lib/perl5/std_common.i index bc25b353f..c36513912 100644 --- a/Lib/perl5/std_common.i +++ b/Lib/perl5/std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_common.i * * SWIG typemaps for STL - common utilities diff --git a/Lib/perl5/std_list.i b/Lib/perl5/std_list.i index 633e40d9a..c6bca18f6 100644 --- a/Lib/perl5/std_list.i +++ b/Lib/perl5/std_list.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_list.i * * SWIG typemaps for std::list types diff --git a/Lib/perl5/std_map.i b/Lib/perl5/std_map.i index c35f21dc7..b19414597 100644 --- a/Lib/perl5/std_map.i +++ b/Lib/perl5/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/perl5/std_pair.i b/Lib/perl5/std_pair.i index 78142ffa6..0712ad762 100644 --- a/Lib/perl5/std_pair.i +++ b/Lib/perl5/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/perl5/std_vector.i b/Lib/perl5/std_vector.i index 7c4f72919..0a61c31e0 100644 --- a/Lib/perl5/std_vector.i +++ b/Lib/perl5/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_vector.i * * SWIG typemaps for std::vector types diff --git a/Lib/perl5/stl.i b/Lib/perl5/stl.i index 946e4b7f0..b19eae58b 100644 --- a/Lib/perl5/stl.i +++ b/Lib/perl5/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/perl5/typemaps.i b/Lib/perl5/typemaps.i index fc6d8f874..7d96f2ace 100644 --- a/Lib/perl5/typemaps.i +++ b/Lib/perl5/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.i * * The SWIG typemap library provides a language independent mechanism for diff --git a/Lib/php/const.i b/Lib/php/const.i index d2d1c75bd..afd7d02b9 100644 --- a/Lib/php/const.i +++ b/Lib/php/const.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * const.i * * Typemaps for constants diff --git a/Lib/php/director.swg b/Lib/php/director.swg index b28f6dbd9..5c1d8d08f 100644 --- a/Lib/php/director.swg +++ b/Lib/php/director.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * director.swg * * This file contains support for director classes that proxy diff --git a/Lib/php/globalvar.i b/Lib/php/globalvar.i index be20a96bc..3463691d5 100644 --- a/Lib/php/globalvar.i +++ b/Lib/php/globalvar.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * globalvar.i * * Global variables - add the variable to PHP diff --git a/Lib/php/php.swg b/Lib/php/php.swg index 77985e3c5..feeb9c5df 100644 --- a/Lib/php/php.swg +++ b/Lib/php/php.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * php.swg * * PHP configuration file diff --git a/Lib/php/phpkw.swg b/Lib/php/phpkw.swg index dab05ed39..c40421062 100644 --- a/Lib/php/phpkw.swg +++ b/Lib/php/phpkw.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * phpkw.swg * ----------------------------------------------------------------------------- */ diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg index 3aff867b4..a48a30b20 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php/phprun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * phprun.swg * * PHP runtime library diff --git a/Lib/php/std_common.i b/Lib/php/std_common.i index a779649dd..092bf012b 100644 --- a/Lib/php/std_common.i +++ b/Lib/php/std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_common.i * * SWIG typemaps for STL - common utilities diff --git a/Lib/php/std_map.i b/Lib/php/std_map.i index 2c9e1fd9a..cfb82f44c 100644 --- a/Lib/php/std_map.i +++ b/Lib/php/std_map.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_map.i * * SWIG typemaps for std::map diff --git a/Lib/php/std_pair.i b/Lib/php/std_pair.i index dc0604dc5..fe45ee676 100644 --- a/Lib/php/std_pair.i +++ b/Lib/php/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_pair.i * * SWIG typemaps for std::pair diff --git a/Lib/php/std_string.i b/Lib/php/std_string.i index eff6951b5..656765194 100644 --- a/Lib/php/std_string.i +++ b/Lib/php/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_string.i * * SWIG typemaps for std::string types diff --git a/Lib/php/std_vector.i b/Lib/php/std_vector.i index 74991cc8c..28c99210c 100644 --- a/Lib/php/std_vector.i +++ b/Lib/php/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_vector.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/php/stl.i b/Lib/php/stl.i index 66b72e073..9d2e91eee 100644 --- a/Lib/php/stl.i +++ b/Lib/php/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/php/typemaps.i b/Lib/php/typemaps.i index cc2341b19..335f6d9f4 100644 --- a/Lib/php/typemaps.i +++ b/Lib/php/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.i. * * SWIG Typemap library for PHP. diff --git a/Lib/pike/pike.swg b/Lib/pike/pike.swg index e72da8fba..2ba27671e 100644 --- a/Lib/pike/pike.swg +++ b/Lib/pike/pike.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * pike.swg * * Pike configuration module. diff --git a/Lib/pike/pikerun.swg b/Lib/pike/pikerun.swg index 875fcf4e2..451a4e092 100644 --- a/Lib/pike/pikerun.swg +++ b/Lib/pike/pikerun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * pikerun.swg * * This file contains the runtime support for Pike modules diff --git a/Lib/pike/std_string.i b/Lib/pike/std_string.i index ca1fad822..0694035bf 100644 --- a/Lib/pike/std_string.i +++ b/Lib/pike/std_string.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_string.i * * SWIG typemaps for std::string diff --git a/Lib/pointer.i b/Lib/pointer.i index 16e11b7d1..8015317d7 100644 --- a/Lib/pointer.i +++ b/Lib/pointer.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * pointer.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/python/ccomplex.i b/Lib/python/ccomplex.i index 30f797d74..28872b985 100644 --- a/Lib/python/ccomplex.i +++ b/Lib/python/ccomplex.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * ccomplex.i * * C complex typemaps diff --git a/Lib/python/director.swg b/Lib/python/director.swg index f3855babe..a57df7315 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * director.swg * * This file contains support for director classes that proxy diff --git a/Lib/python/embed15.i b/Lib/python/embed15.i index 32808b1aa..3c419b9a3 100644 --- a/Lib/python/embed15.i +++ b/Lib/python/embed15.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * embed15.i * * SWIG file embedding the Python interpreter in something else. diff --git a/Lib/python/file.i b/Lib/python/file.i index 294ab9178..359c34d2c 100644 --- a/Lib/python/file.i +++ b/Lib/python/file.i @@ -1,11 +1,7 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * file.i * * Typemaps for FILE* - * From the ideas of Luigi Ballabio * ----------------------------------------------------------------------------- */ %types(FILE *); diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 7d7fdfc72..efca86cf1 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * pycontainer.swg * * Python sequence <-> C++ container wrapper diff --git a/Lib/python/pyiterators.swg b/Lib/python/pyiterators.swg index 8719f73ce..3c39f9710 100644 --- a/Lib/python/pyiterators.swg +++ b/Lib/python/pyiterators.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * pyiterators.swg * * Implement a python 'output' iterator for Python 2.2 or higher. diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index c0d30ee45..d46628551 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * pyrun.swg * * This file contains the runtime support for Python modules diff --git a/Lib/python/typemaps.i b/Lib/python/typemaps.i index 1c87de61d..5d438ecab 100644 --- a/Lib/python/typemaps.i +++ b/Lib/python/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.i * * Pointer handling diff --git a/Lib/ruby/director.swg b/Lib/ruby/director.swg index 76969cadc..de6289cc5 100644 --- a/Lib/ruby/director.swg +++ b/Lib/ruby/director.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * director.swg * * This file contains support for director classes that proxy diff --git a/Lib/ruby/rubyautodoc.swg b/Lib/ruby/rubyautodoc.swg index ade4bde1d..1e6b0d9dc 100644 --- a/Lib/ruby/rubyautodoc.swg +++ b/Lib/ruby/rubyautodoc.swg @@ -1,13 +1,8 @@ -/** - * @file rubyautodoc.swg - * @author gga - * @date Wed May 2 16:41:59 2007 - * - * @brief This file implements autodoc typemaps for some common - * ruby methods. - * - * - */ +/* ----------------------------------------------------------------------------- + * rubyautodoc.swg + * + * This file implements autodoc typemaps for some common ruby methods. + * ----------------------------------------------------------------------------- */ %define AUTODOC(func, str) %feature("autodoc", str) func; diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg index 60c128456..fa4b619f9 100644 --- a/Lib/ruby/rubycontainer.swg +++ b/Lib/ruby/rubycontainer.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * rubycontainer.swg * * Ruby sequence <-> C++ container wrapper diff --git a/Lib/ruby/rubycontainer_extended.swg b/Lib/ruby/rubycontainer_extended.swg index 81936b9da..d2a058586 100644 --- a/Lib/ruby/rubycontainer_extended.swg +++ b/Lib/ruby/rubycontainer_extended.swg @@ -1,17 +1,13 @@ -/** - * @file rubycontainer_extended.swg - * @author gga - * @date Sat May 5 05:36:01 2007 - * - * @brief This file contains additional functions that make containers - * behave closer to ruby primitive types. - * However, some of these functions place some restrictions on - * the underlying object inside of the container and the iterator - * (that it has to have an == comparison function, that it has to have - * an = assignment operator, etc). - * - */ - +/* ----------------------------------------------------------------------------- + * rubycontainer_extended.swg + * + * This file contains additional functions that make containers + * behave closer to ruby primitive types. + * However, some of these functions place some restrictions on + * the underlying object inside of the container and the iterator + * (that it has to have an == comparison function, that it has to have + * an = assignment operator, etc). + * ----------------------------------------------------------------------------- */ /** * Macro used to add extend functions that require operator== in object. diff --git a/Lib/ruby/rubyiterators.swg b/Lib/ruby/rubyiterators.swg index 466ae221b..aba156a2b 100644 --- a/Lib/ruby/rubyiterators.swg +++ b/Lib/ruby/rubyiterators.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * rubyiterators.swg * * Implement a C++ 'output' iterator for Ruby. diff --git a/Lib/ruby/rubyprimtypes.swg b/Lib/ruby/rubyprimtypes.swg index 9e6c361ad..df72e97f4 100644 --- a/Lib/ruby/rubyprimtypes.swg +++ b/Lib/ruby/rubyprimtypes.swg @@ -1,9 +1,5 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * rubyprimtypes.swg - * * ----------------------------------------------------------------------------- */ /* ------------------------------------------------------------ * Primitive Types diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index 5aa43b6cf..a8afc6a10 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * rubyrun.swg * * This file contains the runtime support for Ruby modules diff --git a/Lib/ruby/rubystdautodoc.swg b/Lib/ruby/rubystdautodoc.swg index ad70f7f8b..e14f65902 100644 --- a/Lib/ruby/rubystdautodoc.swg +++ b/Lib/ruby/rubystdautodoc.swg @@ -1,12 +1,8 @@ -/** - * @file rubystdautodoc.swg - * @author gga - * @date Wed May 2 17:20:39 2007 +/* ----------------------------------------------------------------------------- + * rubystdautodoc.swg * - * @brief This file contains autodocs for standard STL functions. - * - * - */ + * This file contains autodocs for standard STL functions. + * ----------------------------------------------------------------------------- */ // // For STL autodocumentation diff --git a/Lib/ruby/rubytracking.swg b/Lib/ruby/rubytracking.swg index 959d2087e..0a36f4a05 100644 --- a/Lib/ruby/rubytracking.swg +++ b/Lib/ruby/rubytracking.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * rubytracking.swg * * This file contains support for tracking mappings from diff --git a/Lib/ruby/rubywstrings.swg b/Lib/ruby/rubywstrings.swg index 862928c95..bb44fbc6e 100644 --- a/Lib/ruby/rubywstrings.swg +++ b/Lib/ruby/rubywstrings.swg @@ -1,15 +1,11 @@ -/** - * @file rubywstrings.swg - * @author - * @date Fri May 4 17:49:40 2007 - * - * @brief Currently, Ruby does not support Unicode or WChar properly, so these - * are still treated as char arrays for now. - * There are other libraries available that add support to this in - * ruby including WString, FXString, etc. - * - * - */ +/* ----------------------------------------------------------------------------- + * rubywstrings.swg + * + * Currently, Ruby does not support Unicode or WChar properly, so these + * are still treated as char arrays for now. + * There are other libraries available that add support to this in + * ruby including WString, FXString, etc. + * ----------------------------------------------------------------------------- */ /* ------------------------------------------------------------ * utility methods for wchar_t strings diff --git a/Lib/ruby/stl.i b/Lib/ruby/stl.i index 66b72e073..9d2e91eee 100644 --- a/Lib/ruby/stl.i +++ b/Lib/ruby/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * stl.i * * Initial STL definition. extended as needed in each language diff --git a/Lib/ruby/typemaps.i b/Lib/ruby/typemaps.i index 2492e2e03..c4db82161 100644 --- a/Lib/ruby/typemaps.i +++ b/Lib/ruby/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.i * * Pointer handling diff --git a/Lib/std/_std_deque.i b/Lib/std/_std_deque.i index 3d68c385f..4234789a8 100644 --- a/Lib/std/_std_deque.i +++ b/Lib/std/_std_deque.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * _std_deque.i * * This file contains a generic definition of std::deque along with diff --git a/Lib/std_except.i b/Lib/std_except.i index af9803a62..769a68995 100644 --- a/Lib/std_except.i +++ b/Lib/std_except.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_except.i * * SWIG library file with typemaps to handle and throw STD exceptions in a diff --git a/Lib/stdint.i b/Lib/stdint.i index 7b48ca388..14fe6195e 100644 --- a/Lib/stdint.i +++ b/Lib/stdint.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * stdint.i * * SWIG library file for ISO C99 types: 7.18 Integer types diff --git a/Lib/stl.i b/Lib/stl.i index c3ade01ea..0b236afda 100644 --- a/Lib/stl.i +++ b/Lib/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * stl.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/swigarch.i b/Lib/swigarch.i index 260b60880..f5aea4678 100644 --- a/Lib/swigarch.i +++ b/Lib/swigarch.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * swigarch.i * * SWIG library file for 32bit/64bit code specialization and checking. diff --git a/Lib/swigrun.i b/Lib/swigrun.i index 17a140968..6026a9151 100644 --- a/Lib/swigrun.i +++ b/Lib/swigrun.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * swigrun.i * * Empty module (for now). Placeholder for runtime libs diff --git a/Lib/tcl/mactclinit.c b/Lib/tcl/mactclinit.c deleted file mode 100644 index 5dcf8e7f3..000000000 --- a/Lib/tcl/mactclinit.c +++ /dev/null @@ -1,93 +0,0 @@ -/* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * - * mactclinit.c - * ----------------------------------------------------------------------------- */ - -/* - * tclMacAppInit.c -- - * - * Provides a version of the Tcl_AppInit procedure for the example shell. - * - * Copyright (c) 1993-1994 Lockheed Missle & Space Company, AI Center - * Copyright (c) 1995-1997 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclMacAppInit.c 1.17 97/01/21 18:13:34 - */ - -#include "tcl.h" -#include "tclInt.h" -#include "tclMacInt.h" - -#if defined(THINK_C) -# include -#elif defined(__MWERKS__) -# include -short InstallConsole _ANSI_ARGS_((short fd)); -#endif - - - -/* - *---------------------------------------------------------------------- - * - * MacintoshInit -- - * - * This procedure calls initalization routines to set up a simple - * console on a Macintosh. This is necessary as the Mac doesn't - * have a stdout & stderr by default. - * - * Results: - * Returns TCL_OK if everything went fine. If it didn't the - * application should probably fail. - * - * Side effects: - * Inits the appropiate console package. - * - *---------------------------------------------------------------------- - */ - -#ifdef __cplusplus -extern "C" -#endif -extern int -MacintoshInit() -{ -#if defined(THINK_C) - - /* Set options for Think C console package */ - /* The console package calls the Mac init calls */ - console_options.pause_atexit = 0; - console_options.title = "\pTcl Interpreter"; - -#elif defined(__MWERKS__) - - /* Set options for CodeWarrior SIOUX package */ - SIOUXSettings.autocloseonquit = true; - SIOUXSettings.showstatusline = true; - SIOUXSettings.asktosaveonclose = false; - InstallConsole(0); - SIOUXSetTitle("\pTcl Interpreter"); - -#elif defined(applec) - - /* Init packages used by MPW SIOW package */ - InitGraf((Ptr)&qd.thePort); - InitFonts(); - InitWindows(); - InitMenus(); - TEInit(); - InitDialogs(nil); - InitCursor(); - -#endif - - TclMacSetEventProc((TclMacConvertEventPtr) SIOUXHandleOneEvent); - - /* No problems with initialization */ - return TCL_OK; -} diff --git a/Lib/tcl/mactkinit.c b/Lib/tcl/mactkinit.c index bfe74029c..78391d445 100644 --- a/Lib/tcl/mactkinit.c +++ b/Lib/tcl/mactkinit.c @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * mactkinit.c * * This is a support file needed to build a new version of Wish. diff --git a/Lib/tcl/std_common.i b/Lib/tcl/std_common.i index 3a6f47042..0718facb8 100644 --- a/Lib/tcl/std_common.i +++ b/Lib/tcl/std_common.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_common.i * * SWIG typemaps for STL - common utilities diff --git a/Lib/tcl/std_pair.i b/Lib/tcl/std_pair.i index 52e96674f..1448d6524 100644 --- a/Lib/tcl/std_pair.i +++ b/Lib/tcl/std_pair.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_pair.i * * Typemaps for std::pair diff --git a/Lib/tcl/std_vector.i b/Lib/tcl/std_vector.i index 273214292..de99a36d0 100644 --- a/Lib/tcl/std_vector.i +++ b/Lib/tcl/std_vector.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * std_vector.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/tcl/stl.i b/Lib/tcl/stl.i index afd121341..40c7584ec 100644 --- a/Lib/tcl/stl.i +++ b/Lib/tcl/stl.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * stl.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/tcl/tcl8.swg b/Lib/tcl/tcl8.swg index c33cc7681..5da1bc07c 100644 --- a/Lib/tcl/tcl8.swg +++ b/Lib/tcl/tcl8.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * tcl8.swg * * Tcl configuration module. diff --git a/Lib/tcl/tclinterp.i b/Lib/tcl/tclinterp.i index 48cdb6066..3b45b6d4b 100644 --- a/Lib/tcl/tclinterp.i +++ b/Lib/tcl/tclinterp.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * tclinterp.i * * Tcl_Interp *interp diff --git a/Lib/tcl/tclopers.swg b/Lib/tcl/tclopers.swg index 26b74203d..f113ccd19 100644 --- a/Lib/tcl/tclopers.swg +++ b/Lib/tcl/tclopers.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * tclopers.swg * * C++ overloaded operators. diff --git a/Lib/tcl/tclresult.i b/Lib/tcl/tclresult.i index ca0106432..c63b3ee19 100644 --- a/Lib/tcl/tclresult.i +++ b/Lib/tcl/tclresult.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * tclresult.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/tcl/tclrun.swg b/Lib/tcl/tclrun.swg index 6387fb008..eb8bd253c 100644 --- a/Lib/tcl/tclrun.swg +++ b/Lib/tcl/tclrun.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * tclrun.swg * * This file contains the runtime support for Tcl modules and includes diff --git a/Lib/tcl/tclsh.i b/Lib/tcl/tclsh.i index 2e8ed3316..160ba8d8f 100644 --- a/Lib/tcl/tclsh.i +++ b/Lib/tcl/tclsh.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * tclsh.i * * SWIG File for building new tclsh program diff --git a/Lib/tcl/tclwstrings.swg b/Lib/tcl/tclwstrings.swg index 2d344c20f..b3b682e30 100644 --- a/Lib/tcl/tclwstrings.swg +++ b/Lib/tcl/tclwstrings.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * tclwstrings.wg * * Utility methods for wchar strings diff --git a/Lib/tcl/typemaps.i b/Lib/tcl/typemaps.i index 2a8f1064a..04a5c78f3 100644 --- a/Lib/tcl/typemaps.i +++ b/Lib/tcl/typemaps.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.i * * SWIG typemap library for Tcl8. This file contains various sorts diff --git a/Lib/tcl/wish.i b/Lib/tcl/wish.i index 077ded61f..260032a81 100644 --- a/Lib/tcl/wish.i +++ b/Lib/tcl/wish.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * wish.i * * SWIG File for making wish diff --git a/Lib/typemaps/attribute.swg b/Lib/typemaps/attribute.swg index 4bc6315b7..4dcf15e2d 100644 --- a/Lib/typemaps/attribute.swg +++ b/Lib/typemaps/attribute.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * attribute.swg * * Attribute implementation diff --git a/Lib/typemaps/carrays.swg b/Lib/typemaps/carrays.swg index 27ca11779..cdeab36b7 100644 --- a/Lib/typemaps/carrays.swg +++ b/Lib/typemaps/carrays.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * carrays.swg * * This library file contains macros that can be used to manipulate simple diff --git a/Lib/typemaps/cdata.swg b/Lib/typemaps/cdata.swg index cab53d31e..8597b7b0c 100644 --- a/Lib/typemaps/cdata.swg +++ b/Lib/typemaps/cdata.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * cdata.swg * * This library file contains macros for manipulating raw C data as strings. diff --git a/Lib/typemaps/cmalloc.swg b/Lib/typemaps/cmalloc.swg index 15f962930..45a6ab990 100644 --- a/Lib/typemaps/cmalloc.swg +++ b/Lib/typemaps/cmalloc.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * cmalloc.swg * * This library file contains macros that can be used to create objects using diff --git a/Lib/typemaps/cpointer.swg b/Lib/typemaps/cpointer.swg index ce1af169e..f797a6895 100644 --- a/Lib/typemaps/cpointer.swg +++ b/Lib/typemaps/cpointer.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * cpointer.swg * * This library file contains macros that can be used to manipulate simple diff --git a/Lib/typemaps/cstrings.swg b/Lib/typemaps/cstrings.swg index 9144da790..c60ef6496 100644 --- a/Lib/typemaps/cstrings.swg +++ b/Lib/typemaps/cstrings.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * cstrings.swg * * This file provides typemaps and macros for dealing with various forms diff --git a/Lib/typemaps/exception.swg b/Lib/typemaps/exception.swg index 17a819cd7..12c4ea658 100644 --- a/Lib/typemaps/exception.swg +++ b/Lib/typemaps/exception.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * exceptions.swg * * This SWIG library file provides language independent exception handling diff --git a/Lib/typemaps/ptrtypes.swg b/Lib/typemaps/ptrtypes.swg index 803377afe..e1bc476ed 100644 --- a/Lib/typemaps/ptrtypes.swg +++ b/Lib/typemaps/ptrtypes.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * ptrtypes.swg * * Value typemaps (Type, const Type&) for "Ptr" types, such as swig diff --git a/Lib/typemaps/swigtypemaps.swg b/Lib/typemaps/swigtypemaps.swg index 08abab028..0e39afe4c 100644 --- a/Lib/typemaps/swigtypemaps.swg +++ b/Lib/typemaps/swigtypemaps.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * swigtypemaps.swg * * Unified Typemap Library frontend diff --git a/Lib/typemaps/typemaps.swg b/Lib/typemaps/typemaps.swg index 6e7505765..4629e8dfa 100644 --- a/Lib/typemaps/typemaps.swg +++ b/Lib/typemaps/typemaps.swg @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * typemaps.swg * * Tcl Pointer handling diff --git a/Lib/uffi/uffi.swg b/Lib/uffi/uffi.swg index 78bd23534..41b085998 100644 --- a/Lib/uffi/uffi.swg +++ b/Lib/uffi/uffi.swg @@ -27,8 +27,6 @@ typedef long size_t; %wrapper %{ -;; $Id$ - (eval-when (compile eval) ;;; You can define your own identifier converter if you want. diff --git a/Lib/wchar.i b/Lib/wchar.i index f106a3529..14de34634 100644 --- a/Lib/wchar.i +++ b/Lib/wchar.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * wchar.i * ----------------------------------------------------------------------------- */ diff --git a/Lib/windows.i b/Lib/windows.i index 08ddc2b22..2c093dacc 100644 --- a/Lib/windows.i +++ b/Lib/windows.i @@ -1,7 +1,4 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * * windows.i * * SWIG library file to support types found in windows.h as well as Microsoft From 3f714e10968dca367dd2cb77839ee01960622abf Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 27 Feb 2010 23:29:39 +0000 Subject: [PATCH 351/352] remove gifplot example from build git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11875 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Makefile.in | 56 +++------------------------------------ Source/Include/swigwarn.h | 2 -- configure.in | 2 -- 3 files changed, 3 insertions(+), 57 deletions(-) diff --git a/Makefile.in b/Makefile.in index 111d7d878..bdfec746e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -184,50 +184,6 @@ java.actionexample: (cd Examples/$(LANGUAGE)/java && $(MAKE) -s $(chk-set-env) $(ACTION)) \ fi -gifplot-library: - @echo $(ACTION)ing Examples/GIFPlot/Lib - @cd Examples/GIFPlot/Lib && $(MAKE) -k -s $(ACTION) - -check-gifplot: \ - check-tcl-gifplot \ - check-perl5-gifplot \ - check-python-gifplot \ - check-java-gifplot \ - check-guile-gifplot \ - check-mzscheme-gifplot \ - check-ruby-gifplot \ - check-ocaml-gifplot \ - check-octave-gifplot \ - check-php-gifplot \ - check-pike-gifplot \ - check-chicken-gifplot \ -# check-lua-gifplot \ -# check-csharp-gifplot \ -# check-modula3-gifplot - -check-%-gifplot: gifplot-library - @if test -z "$(skip-$*)"; then \ - echo $* unknown; \ - exit 1; \ - fi - @passed=true; \ - up=`$(srcdir)/Tools/capitalize $*`; \ - dir="Examples/GIFPlot/$$up"; \ - if $(skip-$*); then \ - echo skipping $$up $(ACTION); \ - elif [ ! -f $$dir/check.list ]; then \ - echo skipping $$up $(ACTION) "(no $$dir/check.list)"; \ - else \ - all=`sed '/^#/d' $$dir/check.list`; \ - for a in $$all; do \ - echo $(ACTION)ing $$dir/$$a; \ - (cd $$dir/$$a && \ - $(MAKE) -k -s $(chk-set-env) $(ACTION)) \ - || passed=false; \ - done; \ - fi; \ - test $$passed = true - # Checks testcases in the test-suite excluding those which are known to be broken check-test-suite: \ check-tcl-test-suite \ @@ -277,7 +233,7 @@ partialcheck-test-suite: partialcheck-%-test-suite: @$(MAKE) -k -s check-$*-test-suite ACTION=partialcheck NOSKIP=1 -check: check-aliveness check-ccache check-examples check-gifplot check-test-suite +check: check-aliveness check-ccache check-examples check-test-suite # Run known-to-be-broken as well as not broken testcases in the test-suite all-test-suite: \ @@ -337,7 +293,7 @@ broken-%-test-suite: # CLEAN ##################################################################### -clean: clean-objects clean-libfiles clean-examples clean-gifplot clean-test-suite clean-docs +clean: clean-objects clean-libfiles clean-examples clean-test-suite clean-docs clean-objects: clean-source clean-ccache @@ -352,9 +308,6 @@ clean-libfiles: clean-examples: @$(MAKE) -k -s check-examples ACTION=clean -clean-gifplot: - @$(MAKE) -k -s check-gifplot ACTION=clean - clean-test-suite: @$(MAKE) -k -s check-test-suite ACTION=clean NOSKIP=1 @@ -364,9 +317,6 @@ clean-%-examples: clean-%-test-suite: @$(MAKE) -k -s check-$*-test-suite ACTION=clean NOSKIP=1 -clean-%-gifplot: - @$(MAKE) -k -s check-$*-gifplot ACTION=clean - clean-ccache: test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s clean) @@ -388,7 +338,7 @@ maintainer-clean: clean-libfiles DISTCLEAN-DEAD = config.status config.log config.cache swig.spec Makefile mkmf.log libtool -distclean: clean-docs distclean-objects clean-examples clean-gifplot distclean-test-suite distclean-dead distclean-ccache +distclean: clean-docs distclean-objects clean-examples distclean-test-suite distclean-dead distclean-ccache distclean-objects: distclean-source diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index b400fbdeb..73cb6e696 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -16,8 +16,6 @@ * numbers in this file. * ----------------------------------------------------------------------------- */ -/* $Id$ */ - #ifndef SWIGWARN_H_ #define SWIGWARN_H_ diff --git a/configure.in b/configure.in index b2403c41b..49076ec8c 100644 --- a/configure.in +++ b/configure.in @@ -2158,8 +2158,6 @@ AC_CONFIG_FILES([ \ Examples/Makefile \ Examples/guile/Makefile \ Examples/xml/Makefile \ - Examples/GIFPlot/Makefile \ - Examples/GIFPlot/Lib/Makefile \ Examples/test-suite/chicken/Makefile \ Examples/test-suite/csharp/Makefile \ Examples/test-suite/guile/Makefile \ From cb64f65bae17ed4eeaa257556f15e18f4742a993 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 27 Feb 2010 23:53:33 +0000 Subject: [PATCH 352/352] SWIG license change - Source moves to GPLv3 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11876 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/CParse/cparse.h | 8 ++++++-- Source/CParse/cscanner.c | 8 ++++++-- Source/CParse/parser.y | 8 ++++++-- Source/CParse/templ.c | 8 ++++++-- Source/CParse/util.c | 8 ++++++-- Source/DOH/base.c | 12 +++++++----- Source/DOH/doh.h | 14 +++++++------- Source/DOH/dohint.h | 15 +++++++-------- Source/DOH/file.c | 12 +++++++----- Source/DOH/fio.c | 12 +++++++----- Source/DOH/hash.c | 12 +++++++----- Source/DOH/list.c | 12 +++++++----- Source/DOH/memory.c | 12 +++++++----- Source/DOH/string.c | 12 +++++++----- Source/DOH/void.c | 12 +++++++----- Source/Include/swigwarn.h | 8 ++++++-- Source/Modules/allegrocl.cxx | 8 ++++++-- Source/Modules/allocate.cxx | 8 ++++++-- Source/Modules/browser.cxx | 8 ++++++-- Source/Modules/cffi.cxx | 8 ++++++-- Source/Modules/chicken.cxx | 8 ++++++-- Source/Modules/clisp.cxx | 8 ++++++-- Source/Modules/contract.cxx | 8 ++++++-- Source/Modules/csharp.cxx | 8 ++++++-- Source/Modules/directors.cxx | 8 ++++++-- Source/Modules/emit.cxx | 8 ++++++-- Source/Modules/guile.cxx | 8 ++++++-- Source/Modules/java.cxx | 8 ++++++-- Source/Modules/lang.cxx | 8 ++++++-- Source/Modules/lua.cxx | 8 ++++++-- Source/Modules/main.cxx | 8 ++++++-- Source/Modules/modula3.cxx | 8 ++++++-- Source/Modules/module.cxx | 8 ++++++-- Source/Modules/mzscheme.cxx | 8 ++++++-- Source/Modules/ocaml.cxx | 8 ++++++-- Source/Modules/octave.cxx | 8 ++++++-- Source/Modules/overload.cxx | 8 ++++++-- Source/Modules/perl5.cxx | 12 ++++++------ Source/Modules/php.cxx | 8 ++++++-- Source/Modules/pike.cxx | 8 ++++++-- Source/Modules/python.cxx | 8 ++++++-- Source/Modules/r.cxx | 8 ++++++-- Source/Modules/ruby.cxx | 8 ++++++-- Source/Modules/s-exp.cxx | 8 ++++++-- Source/Modules/swigmain.cxx | 12 ++++++++---- Source/Modules/swigmod.h | 8 ++++++-- Source/Modules/tcl8.cxx | 8 ++++++-- Source/Modules/typepass.cxx | 8 ++++++-- Source/Modules/uffi.cxx | 8 ++++++-- Source/Modules/utils.cxx | 8 ++++++-- Source/Modules/xml.cxx | 8 ++++++-- Source/Preprocessor/cpp.c | 8 ++++++-- Source/Preprocessor/expr.c | 8 ++++++-- Source/Preprocessor/preprocessor.h | 8 ++++++-- Source/Swig/cwrap.c | 8 ++++++-- Source/Swig/deprecate.c | 8 ++++++-- Source/Swig/error.c | 8 ++++++-- Source/Swig/fragment.c | 8 ++++++-- Source/Swig/getopt.c | 8 ++++++-- Source/Swig/include.c | 8 ++++++-- Source/Swig/misc.c | 8 ++++++-- Source/Swig/naming.c | 8 ++++++-- Source/Swig/parms.c | 8 ++++++-- Source/Swig/scanner.c | 8 ++++++-- Source/Swig/stype.c | 8 ++++++-- Source/Swig/swig.h | 8 ++++++-- Source/Swig/swigfile.h | 8 ++++++-- Source/Swig/swigopt.h | 8 ++++++-- Source/Swig/swigparm.h | 8 ++++++-- Source/Swig/swigscan.h | 8 ++++++-- Source/Swig/swigtree.h | 8 ++++++-- Source/Swig/swigwrap.h | 8 ++++++-- Source/Swig/symbol.c | 8 ++++++-- Source/Swig/tree.c | 8 ++++++-- Source/Swig/typemap.c | 8 ++++++-- Source/Swig/typeobj.c | 8 ++++++-- Source/Swig/typesys.c | 8 ++++++-- Source/Swig/wrapfunc.c | 8 ++++++-- 78 files changed, 480 insertions(+), 197 deletions(-) diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h index a71be786f..ddc5d05dc 100644 --- a/Source/CParse/cparse.h +++ b/Source/CParse/cparse.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * cparse.h * diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index a98bfb47f..f88841c09 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * scanner.c * diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 6f42d2398..9622ce9f3 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * parser.y * diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index 91a1d31ff..8d77cb0ee 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * templ.c * diff --git a/Source/CParse/util.c b/Source/CParse/util.c index efae41051..fa934ffc0 100644 --- a/Source/CParse/util.c +++ b/Source/CParse/util.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * util.c * diff --git a/Source/DOH/base.c b/Source/DOH/base.c index 15827f328..245004f87 100644 --- a/Source/DOH/base.c +++ b/Source/DOH/base.c @@ -1,13 +1,15 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * base.c * * This file contains the function entry points for dispatching methods on * DOH objects. A number of small utility functions are also included. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_base_c[] = "$Id$"; diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index 766e12a34..1ed196058 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -1,14 +1,14 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * doh.h * * This file describes of the externally visible functions in DOH. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. - * - * $Id$ * ----------------------------------------------------------------------------- */ #ifndef _DOH_H diff --git a/Source/DOH/dohint.h b/Source/DOH/dohint.h index 1fc5eb7c9..661bed075 100644 --- a/Source/DOH/dohint.h +++ b/Source/DOH/dohint.h @@ -1,15 +1,14 @@ - /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * dohint.h * * This file describes internally managed objects. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. - * - * $Id$ * ----------------------------------------------------------------------------- */ #ifndef _DOHINT_H diff --git a/Source/DOH/file.c b/Source/DOH/file.c index 65c2336a4..a9ee332bf 100644 --- a/Source/DOH/file.c +++ b/Source/DOH/file.c @@ -1,13 +1,15 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * file.c * * This file implements a file-like object that can be built around an * ordinary FILE * or integer file descriptor. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_file_c[] = "$Id$"; diff --git a/Source/DOH/fio.c b/Source/DOH/fio.c index f544cee64..2ef605c32 100644 --- a/Source/DOH/fio.c +++ b/Source/DOH/fio.c @@ -1,13 +1,15 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * fio.c * * This file implements a number of standard I/O operations included * formatted output, readline, and splitting. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_fio_c[] = "$Id$"; diff --git a/Source/DOH/hash.c b/Source/DOH/hash.c index 045de8b5b..87f8e3c40 100644 --- a/Source/DOH/hash.c +++ b/Source/DOH/hash.c @@ -1,12 +1,14 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * hash.c * * Implements a simple hash table object. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_hash_c[] = "$Id$"; diff --git a/Source/DOH/list.c b/Source/DOH/list.c index 7a1786299..a08cadb5a 100644 --- a/Source/DOH/list.c +++ b/Source/DOH/list.c @@ -1,12 +1,14 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * list.c * * Implements a simple list object. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_list_c[] = "$Id$"; diff --git a/Source/DOH/memory.c b/Source/DOH/memory.c index 1c6063ef3..fcacd6170 100644 --- a/Source/DOH/memory.c +++ b/Source/DOH/memory.c @@ -1,13 +1,15 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * memory.c * * This file implements all of DOH's memory management including allocation * of objects and checking of objects. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_memory_c[] = "$Id$"; diff --git a/Source/DOH/string.c b/Source/DOH/string.c index 141cd58e8..bd36c4094 100644 --- a/Source/DOH/string.c +++ b/Source/DOH/string.c @@ -1,13 +1,15 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * string.c * * Implements a string object that supports both sequence operations and * file semantics. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_string_c[] = "$Id$"; diff --git a/Source/DOH/void.c b/Source/DOH/void.c index 0be01561a..2d684b9cd 100644 --- a/Source/DOH/void.c +++ b/Source/DOH/void.c @@ -1,13 +1,15 @@ /* ----------------------------------------------------------------------------- + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. + * * void.c * * Implements a "void" object that is really just a DOH container around * an arbitrary C object represented as a void *. - * - * Author(s) : David Beazley (beazley@cs.uchicago.edu) - * - * Copyright (C) 1999-2000. The University of Chicago - * See the file LICENSE for information on usage and redistribution. * ----------------------------------------------------------------------------- */ char cvsroot_void_c[] = "$Id$"; diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index 73cb6e696..9f0729a98 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigwarn.h * diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 0b3fb0532..3c6e86cc5 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * allegrocl.cxx * diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx index e37358be6..2e05fd190 100644 --- a/Source/Modules/allocate.cxx +++ b/Source/Modules/allocate.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * allocate.cxx * diff --git a/Source/Modules/browser.cxx b/Source/Modules/browser.cxx index b1bc7349c..592e12783 100644 --- a/Source/Modules/browser.cxx +++ b/Source/Modules/browser.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * browser.cxx * diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 09e97f448..53c44ff66 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * cffi.cxx * diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index 12ef4b454..1d9e9c620 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * chicken.cxx * diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx index 2dc30667f..b1a6f5610 100644 --- a/Source/Modules/clisp.cxx +++ b/Source/Modules/clisp.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * clisp.cxx * diff --git a/Source/Modules/contract.cxx b/Source/Modules/contract.cxx index 518dc2997..7a8543928 100644 --- a/Source/Modules/contract.cxx +++ b/Source/Modules/contract.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * contract.cxx * diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 11daee3c9..d813c2e56 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * csharp.cxx * diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx index 158b53502..6064e1758 100644 --- a/Source/Modules/directors.cxx +++ b/Source/Modules/directors.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * directors.cxx * diff --git a/Source/Modules/emit.cxx b/Source/Modules/emit.cxx index 017f492db..ed75e4d74 100644 --- a/Source/Modules/emit.cxx +++ b/Source/Modules/emit.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * emit.cxx * diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 38ee7b9f5..9e0f43daf 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * guile.cxx * diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 902fdccf6..7a9d739f1 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * java.cxx * diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 56301e72d..a22c06dd0 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * lang.cxx * diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index 78cd7ce96..4640d9ed7 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * lua.cxx * diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index 54b210888..86f279a67 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * main.cxx * diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index f5878c37c..d1e10b974 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * modula3.cxx * diff --git a/Source/Modules/module.cxx b/Source/Modules/module.cxx index 6a0d6bbb9..f4ab560dd 100644 --- a/Source/Modules/module.cxx +++ b/Source/Modules/module.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * module.cxx * diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index 1641b719a..5eb0a58c9 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * mzscheme.cxx * diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx index cfd4fc682..41c30c858 100644 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * ocaml.cxx * diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index ff880fc5a..ab001a48b 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * octave.cxx * diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 14c677783..65deee2de 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * overload.cxx * diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index 177571dea..4c7dba1eb 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -1,10 +1,10 @@ -/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=2:tabstop=8:smarttab: - */ - /* ---------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * perl5.cxx * diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx index e98a16f7d..c44e7c6ce 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * php.cxx * diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index a6da60ce5..6913596d3 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * pike.cxx * diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index 3c7e3de7a..bafd567e0 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * python.cxx * diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 4e816486a..ad83d608a 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * r.cxx * diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index c0a252542..82808b154 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * ruby.cxx * diff --git a/Source/Modules/s-exp.cxx b/Source/Modules/s-exp.cxx index 90791ec70..62b93f7c7 100644 --- a/Source/Modules/s-exp.cxx +++ b/Source/Modules/s-exp.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * s-exp.cxx * diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index 2acdffa9b..1ed85e82e 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -1,11 +1,15 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * - * Simplified Wrapper and Interface Generator (SWIG) + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigmain.cxx * + * Simplified Wrapper and Interface Generator (SWIG) + * * This file is the main entry point to SWIG. It collects the command * line options, registers built-in language modules, and instantiates * a module for code generation. If adding new language modules diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 72bfa415e..813c56cb9 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigmod.h * diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 54648c2b0..94191abcc 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * tcl8.cxx * diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx index 9b42bc1a3..8d4ddda11 100644 --- a/Source/Modules/typepass.cxx +++ b/Source/Modules/typepass.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * typepass.cxx * diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index 44ec972de..ac17ca925 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * uffi.cxx * diff --git a/Source/Modules/utils.cxx b/Source/Modules/utils.cxx index bf8211903..3fe7a2709 100644 --- a/Source/Modules/utils.cxx +++ b/Source/Modules/utils.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * utils.cxx * diff --git a/Source/Modules/xml.cxx b/Source/Modules/xml.cxx index 2edd01cf0..bcfac1acc 100644 --- a/Source/Modules/xml.cxx +++ b/Source/Modules/xml.cxx @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * xml.cxx * diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index c4c5d6861..feaa82ff8 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * cpp.c * diff --git a/Source/Preprocessor/expr.c b/Source/Preprocessor/expr.c index 4da24a774..3e3f39480 100644 --- a/Source/Preprocessor/expr.c +++ b/Source/Preprocessor/expr.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * expr.c * diff --git a/Source/Preprocessor/preprocessor.h b/Source/Preprocessor/preprocessor.h index 3579eede2..8f98dae15 100644 --- a/Source/Preprocessor/preprocessor.h +++ b/Source/Preprocessor/preprocessor.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * preprocessor.h * diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index f4c925206..4fe7236c5 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * cwrap.c * diff --git a/Source/Swig/deprecate.c b/Source/Swig/deprecate.c index 475d2c6cf..f25b9a650 100644 --- a/Source/Swig/deprecate.c +++ b/Source/Swig/deprecate.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * deprecate.c * diff --git a/Source/Swig/error.c b/Source/Swig/error.c index 3271f93fc..fa82ad8d9 100644 --- a/Source/Swig/error.c +++ b/Source/Swig/error.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * error.c * diff --git a/Source/Swig/fragment.c b/Source/Swig/fragment.c index 510a01875..896461b30 100644 --- a/Source/Swig/fragment.c +++ b/Source/Swig/fragment.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * fragment.c * diff --git a/Source/Swig/getopt.c b/Source/Swig/getopt.c index cbd051d9f..f6f196bfd 100644 --- a/Source/Swig/getopt.c +++ b/Source/Swig/getopt.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * getopt.c * diff --git a/Source/Swig/include.c b/Source/Swig/include.c index dd4c7e020..baae44bb8 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * include.c * diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 1fd8f7f90..19050fd51 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * misc.c * diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 9738bed66..08c4f6b5d 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * naming.c * diff --git a/Source/Swig/parms.c b/Source/Swig/parms.c index 90a072a7e..283a2f5c2 100644 --- a/Source/Swig/parms.c +++ b/Source/Swig/parms.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * parms.c * diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 507c8c748..db7f0a06e 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * scanner.c * diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 17247b051..fd6a06ca0 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * stype.c * diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 4bd08be3a..6aff97955 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swig.h * diff --git a/Source/Swig/swigfile.h b/Source/Swig/swigfile.h index 92c7945e6..632e821e2 100644 --- a/Source/Swig/swigfile.h +++ b/Source/Swig/swigfile.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigfile.h * diff --git a/Source/Swig/swigopt.h b/Source/Swig/swigopt.h index 11eb5ba99..586f8bbc4 100644 --- a/Source/Swig/swigopt.h +++ b/Source/Swig/swigopt.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigopt.h * diff --git a/Source/Swig/swigparm.h b/Source/Swig/swigparm.h index 4a928999e..060225f6b 100644 --- a/Source/Swig/swigparm.h +++ b/Source/Swig/swigparm.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigparm.h * diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h index 2adf7b2be..d52124c60 100644 --- a/Source/Swig/swigscan.h +++ b/Source/Swig/swigscan.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigscan.h * diff --git a/Source/Swig/swigtree.h b/Source/Swig/swigtree.h index 5b43006a9..6799398c9 100644 --- a/Source/Swig/swigtree.h +++ b/Source/Swig/swigtree.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigtree.h * diff --git a/Source/Swig/swigwrap.h b/Source/Swig/swigwrap.h index 0dcf88059..b1f596f72 100644 --- a/Source/Swig/swigwrap.h +++ b/Source/Swig/swigwrap.h @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * swigwrap.h * diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index 94fb7c21e..73a136a4a 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * symbol.c * diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c index 98ae9ed16..c76ac958e 100644 --- a/Source/Swig/tree.c +++ b/Source/Swig/tree.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * tree.c * diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 93f7c4db7..aaf156d8e 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * typemap.c * diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index 81a5aeff1..9ccdfbf7b 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * typeobj.c * diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 88fdfc3fd..8d35c9746 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * typesys.c * diff --git a/Source/Swig/wrapfunc.c b/Source/Swig/wrapfunc.c index 11518bfc2..2c9f7c86a 100644 --- a/Source/Swig/wrapfunc.c +++ b/Source/Swig/wrapfunc.c @@ -1,6 +1,10 @@ /* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * This file is part of SWIG, which is licensed as a whole under version 3 + * (or any later version) of the GNU General Public License. Some additional + * terms also apply to certain portions of SWIG. The full details of the SWIG + * license and copyrights can be found in the LICENSE and COPYRIGHT files + * included with the SWIG source code as distributed by the SWIG developers + * and at http://www.swig.org/legal.html. * * wrapfunc.c *